C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# StringReader ClassStringReader 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[SerializableAttribute] [ComVisibleAttribute(true)] public class StringReader : TextReader C# StringReader ConstructorsStringReader has the following constructors.
C# StringReader MethodsFollowing are the methods of StringReader class.
C# StringReader ExampleIn 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. using System; using System.IO; namespace CSharpProgram { class Program { static void Main(string[] args) { StringWriter str = new StringWriter(); str.WriteLine("Hello, this message is read by StringReader class"); str.Close(); // Creating StringReader instance and passing StringWriter StringReader reader = new StringReader(str.ToString()); // Reading data while (reader.Peek() > -1) { Console.WriteLine(reader.ReadLine()); } } } } Output: Hello, this message is read by StringReader class
Next TopicC# FileInfo
|