Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我正在尝试从.csv读取信息,并将其放入C#的数组中。有谁能告诉我为什么代码没有';不行?_C#_Arrays_Csv_Split - Fatal编程技术网

我正在尝试从.csv读取信息,并将其放入C#的数组中。有谁能告诉我为什么代码没有';不行?

我正在尝试从.csv读取信息,并将其放入C#的数组中。有谁能告诉我为什么代码没有';不行?,c#,arrays,csv,split,C#,Arrays,Csv,Split,编辑:通过注释解决 StreamReader sr = new StreamReader("Details.csv"); 档案里有 //详细阅读 字符串[,]数据=新字符串[hML,3]; string[]tempArr=新字符串[3]; 字符串lineIn=“”; 对于(int i=0;i

编辑:通过注释解决

StreamReader sr = new StreamReader("Details.csv");
档案里有

//详细阅读
字符串[,]数据=新字符串[hML,3];
string[]tempArr=新字符串[3];
字符串lineIn=“”;
对于(int i=0;i

当它试图在逗号处拆分时,我得到一个“System.NullReferenceException:“Object reference not set to a instance of a Object.”错误,我不知道这意味着什么,这意味着如果我冒险猜测它是sr变量,那么您试图在初始化之前访问该对象,aa在你发布的代码中没有声明

在本节之前声明了20行,我认为没有必要显示所有代码。是和否。。。在这种情况下,我们必须猜测什么类型的srrepresents@StewartRitchiesr是我的StreamReader命令的名称,不用于扩展讨论;这段对话已经结束。
//reading in details
            string[ , ] data = new string[hML, 3];
            string[] tempArr = new string[3];
            string lineIn = "";
            for (int i = 0; i < hML; i++)
            {
                lineIn = sr.ReadLine();
                tempArr = lineIn.Split(Convert.ToChar(","));
                data[i, 0] = tempArr[0];
                data[i, 1] = tempArr[1];
                data[i, 2] = tempArr[2];
            }