Return Column from two dimensional array - CSharp System

CSharp examples for System:Array Dimension

Description

Return Column from two dimensional array

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   w  w  w  .  j  a  v a  2  s. c o m

public class Main{
        public static IEnumerable<T> Column<T>(this T[,] data, int column)
        {
            for (int j = 0; j < data.GetLength(1); j++)
                yield return data[column, j];
        }
}

Related Tutorials