我有以下程序,它只是將兩個矩陣從.txt文件讀入二維數組。我從開發人員命令提示符下運行它VS2012像第一張圖片兩個.txt文件的命令行參數
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Assignment3
{
class Program
{
static void Main(string[] args)
{
int[,] matrix1 = new int[3, 3]; int[,] matrix2 = new int[3, 3]; int[,] matrix3 = new int[3, 3];
int i = 0, j = 0, k = 0;
#region Reading Matrices From Files
string text = System.IO.File.ReadAllText(@"Matrix1.txt");
foreach (var row in text.Split('\n'))
{
j = 0;
foreach (var col in row.Trim().Split(' '))
{
matrix1[i, j] = int.Parse(col.Trim());
j++;
}
i++;
}
Console.WriteLine("Execution Starts Here");
Console.WriteLine("\nMatrix1 Has been read from file Matrix1.txt...\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.Write(String.Format("{0}\t", matrix1[i,j]));
}
Console.WriteLine();
}
string text2 = System.IO.File.ReadAllText(@"Matrix2.txt");
i = 0;
foreach (var row in text2.Split('\n'))
{
j = 0;
foreach (var col in row.Trim().Split(' '))
{
matrix2[i, j] = int.Parse(col.Trim());
j++;
}
i++;
}
Console.WriteLine("\n\nMatrix2 Has been read from file Matrix2.txt...\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 3; j++)
{
Console.Write(String.Format("{0}\t", matrix2[i, j]));
}
Console.WriteLine();
}
#endregion
我認爲這與喜歡的命令參數的數目一些事情。任何人都請幫助我。
提示:'無效的主要(字串[] args)' – leppie