using( StreamReader sr = File.OpenText(@"D:\1.txt"))//源文件放在D盘下
{
string s = "";
string[] str;
string[] strA;
string[] strA0;
string[] strA1;
string[] strA2;
string[] strB;
string[] strC;
s = sr.ReadToEnd();//读取全部
str = s.Split(new char[3] { 'A', 'B', 'C' });//分成3块数据
#region 赋值多维数组A
strA = str[1].Trim().Split( '\r' );
strA0 = strA[0].Trim().Split(new char[2] { '\n', ' ' });
strA1 = strA[1].Trim().Split(new char[2] { '\n', ' ' });
strA2 = strA[2].Trim().Split(new char[2] { '\n', ' ' });
double[,] A = new double[3,4];
int a0 = 0;
foreach (string stra0 in strA0)
{
A[0,a0++] = Convert.ToDouble(stra0);
}
int a1 = 0;
foreach (string stra1 in strA1)
{
A[1,a1++] = Convert.ToDouble(stra1);
}
int a2 = 0;
foreach (string stra2 in strA2)
{
A[2,a2++] = Convert.ToDouble(stra2);
}
#endregion
#region 赋值数组B
strB = str[2].Trim().Split(' ');
double[] B = new double[strB.Length];
int b = 0;
foreach (string strb in strB)
{
B[b++] = Convert.ToDouble(strb);
}
#endregion
#region 赋值数组C
strC = str[3].Trim().Split(' ');
double[] C = new double[strC.Length];
int c = 0;
foreach (string strc in strC)
{
C[c++] = Convert.ToDouble(strc);
}
#endregion
}