publicationskeron.blogg.se

Sequential characters
Sequential characters






sequential characters

  • StringReader: It is used to read text from a string.
  • StreamReader: It is used to read characters from a byte stream in a particular encoding.
  • We can work with TextReader with the help of its two derived classes i.e. Its inheritance hierarchy is shown below: TextReader class is derived from an abstract class MarshalByRefObject. This instance can be used to call the methods of TextReader class to read content from the file. The File.OpenText() method returns an object of the StreamReader class which is the derived class of TextReader and thus helps in creating a useful instance of TextReader class in the code. The OpenText() method takes the location of the file as input and then it opens an existing UTF-8 encoded text file at the same location for reading. As TextReader is an abstract class, we cannot create its instance directly using ‘new’ keyword but we can use OpenText() method of the File class to achieve the same, as shown below: TextReader text_reader = File.OpenText(file_path) In order to work with TextReader, it is necessary to import System.IO namespace in our code. The advantage of working with ‘using’ block is that it releases the memory acquired by the object specified inside it after the work of the object is completed and the object is no longer required.

    sequential characters

    We can also create TextReader with the help of ‘using’ block as shown below: using(TextReader text_reader = File.OpenText(file_path)) Then, with the help of the text_reader, we can use the methods of TextReader class in order to read content from the file. The above statement will open a file at the location specified by ‘file_path’. Syntax of creating TextReader is as follows: TextReader text_reader = File.OpenText(file_path)

    #Sequential characters software#

    Web development, programming languages, Software testing & others Start Your Free Software Development Course








    Sequential characters