Search code examples
c#stringreader

How to reset position in StringReader to begining of String?


I have the following code:

StringReader contentReader = new StringReader(this.dataContent.ToString());

After I parse my DataContent, I need to reset the poistion of the contentReader to begining of the string. How do I do it? I dont see a set poistion option in StringReader


Solution

  • Set it to a new instance of StringReader. I don't believe you can change the position of an existing one.

    contentReader = new StringReader(this.dataContent.ToString());