get Column from two dimensional array - CSharp System

CSharp examples for System:Array Dimension

Description

get Column from two dimensional array

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*ww  w  .  java2 s .co m*/

public class Main{
        public static int[] getColumn(int[,] array, int index)
        {
            int length = array.GetLength(0);
            int[] slice = new int[length];
            for (int i = 0; i < length; i++)
            {
                slice[i] = array[i, index];
            }
            return slice;
        }
}

Related Tutorials