【发布时间】:2017-04-19 13:35:29
【问题描述】:
我是 C# 新手,正在尝试学习如何将 2D 数组的各个行发送到函数。我有一个 3 行 2 列的二维数组。如果我想将第三行发送到一个名为calculate 的函数,你能告诉我怎么做吗?
namespace test
{
class Program
{
static void Main(string[] args)
{
string[,] array2Db = new string[3, 2] { { "one", "two" }, { "three", "four" }, { "five", "six" } };
calculate(array2Db[2,0]); //I want to send only the 3rd row to this array
//This array may contain millions of words. Therefore, I can't pass each array value individually
}
void calculate(string[] words)
{
for (int i = 0; i < 2; i++)
{
Console.WriteLine(words);
}
}
}
}
任何帮助将不胜感激
【问题讨论】: