BinaryReader.ReadUInt16 Method

Definition

Important

This API is not CLS-compliant.

Reads a 2-byte unsigned integer from the current stream using little-endian encoding and advances the position of the stream by two bytes.

public:
 virtual System::UInt16 ReadUInt16();
[System.CLSCompliant(false)]
public virtual ushort ReadUInt16 ();
[<System.CLSCompliant(false)>]
abstract member ReadUInt16 : unit -> uint16
override this.ReadUInt16 : unit -> uint16
Public Overridable Function ReadUInt16 () As UShort

Returns

A 2-byte unsigned integer read from this stream.

Attributes

Exceptions

The end of the stream is reached.

The stream is closed.

An I/O error occurred.

Remarks

BinaryReader does not restore the file position after an unsuccessful read.

BinaryReader reads this data type in little-endian format.

For a list of common I/O tasks, see Common I/O Tasks.

Applies to

See also