How to read character in a file 1 by 1 c#

前端 未结 4 555
夕颜
夕颜 2021-01-05 05:34

I want my program to read a text file all characters 1 by 1 and whereever it finds inverted comma ( \" ), it adds a semicolon before that inverted comma. For eg we have a pa

4条回答
  •  醉话见心
    2021-01-05 06:12

    Do you have to read in character by character? The following code will do the whole thing as a block and return you a list containing all your lines.

    var contents = File.ReadAllLines (@"C:\Users\user1\Documents\data.txt")
                       .Select (l => l.Replace ("\"", ";\""));
    

提交回复
热议问题