SerialPort.DiscardNull 属性

定义

获取或设置一个值,该值指示 null 字节在端口和接收缓冲区之间传输时是否被忽略。Gets or sets a value indicating whether null bytes are ignored when transmitted between the port and the receive buffer.

public:
 property bool DiscardNull { bool get(); void set(bool value); };
public bool DiscardNull { get; set; }
[System.ComponentModel.Browsable(true)]
public bool DiscardNull { get; set; }
member this.DiscardNull : bool with get, set
[<System.ComponentModel.Browsable(true)>]
member this.DiscardNull : bool with get, set
Public Property DiscardNull As Boolean

属性值

Boolean

如果忽略 Null 字节,则为 true;否则为 falsetrue if null bytes are ignored; otherwise false. 默认值为 falseThe default is false.

属性

例外

此端口处于无效状态。The port is in an invalid state.

- 或 --or- 尝试设置基础端口状态失败。An attempt to set the state of the underlying port failed. 例如,从此 SerialPort 对象传递的参数无效。For example, the parameters passed from this SerialPort object were invalid.

流已关闭。The stream is closed. 这可能会因为尚未调用 Open() 方法或已调用了 Close() 方法而发生。This can occur because the Open() method has not been called or the Close() method has been called.

注解

此值通常应设置为 false ,尤其是对于二进制传输。This value should normally be set to false, especially for binary transmissions. 将此属性设置为 true 可能会导致 UTF32 和 UTF16 编码字节出现意外的结果。Setting this property to true can cause unexpected results for UTF32- and UTF16-encoded bytes.

适用于