是否有一种标准方法或属性来获取C#中矢量形式的多维数组的所有值?
int[,] array = new int[2, 2] { {1, 2}, {1, 2} };
int[] vector = array.AllValues(); // ??
答案 0 :(得分:0)
选中此一项:-
int[,] array = new int[,] {{1,2},{3,4},{5,6}};
int[] vector = array.Cast<int>().ToArray();
已测试:-
class Program
{
static void Main(string[] args)
{
int[,] array = new int[,] { { 1, 2 }, { 3, 4 }, { 5, 6 } };
int[] vector = array.Cast<int>().ToArray();
Console.ReadKey();
}
}