日期:2014-05-18  浏览次数:20943 次

列读取的问题,大家帮帮忙?
比如说我有一个txt文本格式是:
00001
01000
01100
10000
01111
00001
01111
01110
01111
01101
..
...
....
这样的,但现在我要获取第一纵向的数据,比如说我要获取的是
0
0
0
1
0
0
0
0
.
.
.
然后读到第64行的时候在从另一个纵向读,读完全部的纵向(比如说有5纵),在从65行开始,以此循环读取,从中判断如果为1,读取在第几行....有没有什么思路给个,或者是什么办法!

------解决方案--------------------
C# code
int column = 5;
string[] lines = File.ReadAllLines(@"E:\a.txt");
string[] result = new string[lines.Length * column];

for (int i = 0; i < lines.Length; i++)
{
    string[] arr = Array.ConvertAll(lines[i].ToCharArray(), v1 => v1.ToString());
    for (int j = 0; j < column; j++)
    {
        result[j * lines.Length + i] = arr[j];
    }
}