What's the best way to extract a one-dimensional array from a rectangular array in C#?
问题 Say I have a rectangular string array - not a jagged array string[,] strings = new string[8, 3]; What's the best way to extract a one-dimensional array from this (either a single row or a single column)? I can do this with a for loop, of course, but I'm hoping .NET has a more elegant way built in. Bonus points for converting the extracted string array to an object array. 回答1: For a rectangular array: string[,] rectArray = new string[3,3] { {"a", "b", "c"}, {"d", "e", "f"}, {"g", "h", "i"} };