C#如何将文本一行一行读到数组里

RT,求代码

using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string _FileFullPath = "D:\test.txt";
var _Strs = new List<string>();
if (File.Exists(_FileFullPath))
{
StreamReader _Sr = new StreamReader(_FileFullPath);
while (!_Sr.EndOfStream)
{
var _Str = _Sr.ReadLine();
// 将_Str 存入数组中即可
_Strs.Add(_Str);
// Console.WriteLine(_Str);
}
}
}

}
}
温馨提示:答案为网友推荐,仅供参考
相似回答