📜  C# 获取二维数组的列 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:17.682000             🧑  作者: Mango

代码示例1
public class CustomArray
{
    public T[] GetColumn(T[,] matrix, int columnNumber)
    {
        return Enumerable.Range(0, matrix.GetLength(0))
                .Select(x => matrix[x, columnNumber])
                .ToArray();
    }

    public T[] GetRow(T[,] matrix, int rowNumber)
    {
        return Enumerable.Range(0, matrix.GetLength(1))
                .Select(x => matrix[rowNumber, x])
                .ToArray();
    }
}