我有以下程序来读取测试文件
public static string[] method1()
{
//List<string[]> allLines = new List<string[]>();
TextReader tr = new StreamReader("data.txt");
// write a line of text to the file
string word = tr.ReadLine();
//now split this line into words
string[] val = word.Split(new Char[] { ',' });
//Console.WriteLine(val[0]);
//Console.WriteLine(val[1]);
//Console.ReadLine();
return val;
}
public static void method2()
{
method1();
var value1= val[0];
//Console.WriteLine(val[0]);
}
它显示错误名称“val”在当前上下文中不存在。如何解决这个问题?