.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace assignment_4
{
    class Program
    {
        static void Main(string[] args)
        {
            
            int txtlength = 0;
            StreamReader sr1 = new StreamReader("A.txt");
            StreamReader sr2 = new StreamReader("A.txt");
            StreamReader sr3 = new StreamReader("A.txt");
            string a = sr2.ReadLine();

            string line = sr1.ReadLine();
            string[] tmp = line.Split('\t');          
            int i = tmp.Length;
            Console.WriteLine(i);//行數
         
            while (a!=null)
            {
                txtlength++;
                a=sr2.ReadLine();
            }
            Console.WriteLine(txtlength);//列數

            double[,] matrix01 = new double[txtlength,tmp.Length];

            while(sr3.Peek()>=0)
            {
                int t = 0;
                string c = sr3.ReadLine();
                string[]tmp2=line.Split('\t');

                for(int p=0;p!=txtlength;p++)
                {
                    for(int j=0;j!=tmp.Length;j++)
                    {
                        matrix01[p,j] = Convert.ToDouble(tmp2[t]);
                        t++;
                    }                   
                }
                
            }
            for (int p = 0; p != txtlength; p++)
            {
                for (int j = 0; j != tmp.Length; j++)
                {
                    Console.Write(matrix01[p, j]+'\t');
                }
                Console.WriteLine();
			}   
        }
    }
}
;