C# StringReader Class
StringReader class is used to read data written by the StringWriter class. It is subclass of TextReader class. It enables us to read a string synchronously or asynchronously. It provides constructors and methods to perform read operations.
C# StringReader Signature
C# StringReader Constructors
StringReader has the following constructors.
|Initializes a new instance of the StringReader class that reads from the specified string.
C# StringReader Methods
Following are the methods of StringReader class.
|It is used to close the StringReader.
|It is used to release all resources used by the TextReader object.
|It determines whether the specified object is equal to the current object or not.
|It allows an object to try to free resources and perform other cleanup operations.
|It serves as the default hash function.
|It is used to get the type of the current instance.
|It is used to return the next available character but does not consume it.
|It is used to read the next character from the input string.
|It is used to read a line of characters from the current string.
|It is used to read a line of characters asynchronously from the current string.
|It is used to read all the characters from the current position to the end of the string.
|It is used to read all the characters from the current position to the end of the string asynchronously.
|It is used to return a string that represents the current object.
C# StringReader Example
In the following example, StringWriter class is used to write the string information and StringReader class is used to read the string, written by the StringWriter class.
Hello, this message is read by StringReader class