1 - 我有我的一些形式变量:如何读取文本文件行变量而不是文本
string BE1835 = "A";
string WB5884 = "B";
string S49807 = "C";
string D35950 = "D";
2 - 我有文本文件中含有较多的线路为:
line1
BE1835
S49807
line4
line5
3-我使用该代码来读取文本文件
int counter = 0;
string line;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader(@JSS_File_Path_01);
while ((line = file.ReadLine()) != null)
{
//read line 3,6,7,8,10
if (counter == 1 || counter == 2)
{
final_cons_Code += line;
}
counter++;
}
file.Close();
label4.Text = final_cons_Code;
5-结果:BE1835S49807
现在我去的结果是AC不BE1835S49807
谢谢
,则不应使用您的变量名称与您正在比较的内容。使用字典进行适当的查找。 – Cyral 2015-02-09 23:17:53
文件中内容的'Delimiter'是什么??我会'谷歌string.Split()'方法以及'File.ReadAllText()'方法'System.IO'类 – MethodMan 2015-02-09 23:22:04