In C#, how can I create a TextReader object from a string (without writing to disk)

后端 未结 6 481
悲哀的现实
悲哀的现实 2020-12-29 00:56

I\'m using A Fast CSV Reader to parse some pasted text into a webpage. The Fast CSV reader requires a TextReader object, and all I have is a string. What\'s the best way to

6条回答
  •  心在旅途
    2020-12-29 01:14

    Use System.IO.StringReader :

    using(TextReader sr = new StringReader(yourstring))
    {
        DoSomethingWithATextReader(sr);
    }
    

提交回复
热议问题