text file: Reading line by line C#

后端 未结 5 437
太阳男子
太阳男子 2021-01-04 19:38

So, let\'s say i have a text file with 20 lines, with on each line different text. i want to be able to have a string that has the first line in it, but when i do NextLine()

5条回答
  •  无人及你
    2021-01-04 20:12

    The ReadLine method already reads the next line in the StreamReader, you don't need the counter, or your custom function for that matter. Just keep reading until you reach your 20 lines or until the file ends.

提交回复
热议问题