日期:2014-05-17 浏览次数:20908 次
111111 2222222 33333 44444 55555555 66666 77777 888888 999999 00000 aaaa bbbb ccccc ddddd eeeee fffff ggggg hhhhh jjjjj kkkk
string myfile = mypath + "\\atm.txt"; string[] mytmpstring = File.ReadAllLines(myfile,Encoding.Default); string[] mybh = null; string[] array2 = null; for (int i = 0; i < mytmpstring.Length; i++) { array2 = mytmpstring[i].Split('\t'); for (int j=0; j < array2.Length; j++) { mylist[i][j] = array2[j] ; } }
string myfile = mypath + "\\atm.txt"; string[] mytmpstring = File.ReadAllLines(myfile,Encoding.Default); //string[] mylistf = mytmpstring.Split("\r\n"); string[] mybh = null; for (int i = 0; i < mytmpstring.Length; i++) { foreach (string s in mytmpstring) { mybh = s.Split('\t'); foreach(string t in mybh) { for (int y=0; y < mybh.Length; y++) { mylist[i][y] = t; } } } }
string[] mytmpstring = File.ReadAllLines(myfile, Encoding.Default); string[] mybh = null; string[] array2 = null; int first = mytmpstring.Length; string[][] mylist = new string[first][]; for (int i = 0; i < mytmpstring.Length; i++) { array2 = mytmpstring[i].Split('\t'); mylist[i] = new string[array2.Length]; for (int j = 0; j < array2.Length; j++) { mylist[i][j] = array2[j]; } }
------解决方案--------------------
另外,你的那个数据用
mytmpstring[i].Split('\t');
貌似不妥
换成这个看
array2 = mytmpstring[i].Split(' ');
------解决方案--------------------
你是要二维数组还是嵌套数组,如果是 string[][] 这样的嵌套数组
string[] lines = File.ReadAllLines("路径"); string[][] mylist = new string[lines.Length][]; for (int i = 0; i < lines.Length; i++) { mylist[i] = lines[i].Split('\t'); }