Answers for "c# 2d array given dimentions"

C#
13

c# length 2d array

int rowsOrHeight = ary.GetLength(0);
int colsOrWidth = ary.GetLength(1);
Posted by: Guest on May-18-2020
0

C# get column of 2d array

public class CustomArray<T>
{
    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();
    }
}
Posted by: Guest on October-27-2020

C# Answers by Framework

Browse Popular Code Answers by Language