楼主的意思是这样吗?
string str1="", str2="", str3="";//定义用于接收文本中的字符串
string[] str = System.IO.File.ReadAllLines(@"D:\Documents\Visual Studio 2010\Projects\汽水问题\string\txtselect.txt", Encoding.Default);
for (int i = 0; i < str.Length; i++)
{
if (i == 0)
str1 = str[0];
else if (i == 1)
str2 = str[1];
else if (i == 2)
str3 = str[2];
}
Console.WriteLine("{0}\n{1}\n{2}",str1,str2,str3); |