Is there a standard method or property to obtain all the values of a multidimensional array in form of a vector in C#?
int[,] array = new int[2, 2] { {1, 2}, {1, 2} };
int[] vector = array.AllValues(); // ??
Is there a standard method or property to obtain all the values of a multidimensional array in form of a vector in C#?
int[,] array = new int[2, 2] { {1, 2}, {1, 2} };
int[] vector = array.AllValues(); // ??
Check This one:-
int[,] array = new int[,] {{1,2},{3,4},{5,6}};
int[] vector = array.Cast<int>().ToArray();
Tested:-
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();
}
}