ArrayExtensions.GetColumn<T>(T[,], Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns an enumerable that returns the items from a given column in a given 2D T
array instance.
This extension should be used directly within a foreach
loop:
int[,] matrix =
{
{ 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 }
};
foreach (ref int number in matrix.GetColumn(1))
{
// Access the current number by reference here...
}
The compiler will take care of properly setting up the foreach
loop with the type returned from this method.
public static Microsoft.Toolkit.HighPerformance.Enumerables.Array2DColumnEnumerable<T> GetColumn<T> (this T[,] array, int column);
static member GetColumn : 'T[,] * int -> Microsoft.Toolkit.HighPerformance.Enumerables.Array2DColumnEnumerable<'T>
<Extension()>
Public Function GetColumn(Of T) (array As T(,), column As Integer) As Array2DColumnEnumerable(Of T)
Type Parameters
- T
The type of elements in the input 2D T
array instance.
Parameters
- array
- T[,]
The input T
array instance.
- column
- Int32
The target column to retrieve (0-based index).
Returns
A wrapper type that will handle the column enumeration for array
.
Remarks
The returned Array2DColumnEnumerable<T> value shouldn't be used directly: use this extension in a foreach
loop.