Export (0) Print
Expand All

BinaryReader.ReadChar Method

Reads the next character from the current stream and advances the current position of the stream in accordance with the Encoding used and the specific character being read from the stream.

Namespace:  System.IO
Assemblies:   mscorlib (in mscorlib.dll)
  System.IO (in System.IO.dll)

abstract ReadChar : unit -> char  
override ReadChar : unit -> char

Return Value

Type: System.Char
A character read from the current stream.

ExceptionCondition
EndOfStreamException

The end of the stream is reached.

ObjectDisposedException

The stream is closed.

IOException

An I/O error occurs.

ArgumentException

A surrogate character was read.

If the ReadChar method attempts to read a surrogate character in the stream an exception will be raised and the position in the stream will advance. The position is restored to the original location before ReadChar was called if the stream is seekable; however, if the stream is unseekable, the position will not be corrected. If surrogate characters can be expected in the stream, use the ReadChars method instead.

Because of data formatting conflicts, using this method with the following encodings is not recommended:

  • UTF-7

  • ISO-2022-JP

  • ISCII

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

The following code example shows how to read and write data using memory as a backing store.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft