C#两个类之间变量的变化(串口调用的时候出现了问题)



这个是我的串口打开之后出现的问题,我从另一个类中调用这个类的close事件,结果这个类的串口竟然出现了NULL这个改变。。。。。。不太清楚发生了什么,希望有人能回答下。

我觉得不爽之后决定直接在这个类中直接进行serialport关闭行为,出现了上面这种错误
有人能告诉我该怎么改吗
c#
串口
------解决方案--------------------你直接调用close事件,能保证port肯定不为空吗,肯定创建了吗
------解决方案--------------------先判断端口的状态,如果是OPEN 则关闭
------解决方案--------------------端口成功打开时,除了一个成功的标示值以外,还应该有个大于0的返回值(我的串口设备是这样的)
当你关闭端口的时候,是否引用了这个返回值?
简单点说,就是你关闭的端口是不是你刚才打开的端口