Jagged 2D Image Enumerable - CSharp System.Collections

CSharp examples for System.Collections:IEnumerable

Description

Jagged 2D Image Enumerable

Demo Code


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

public class Main{
        private static IEnumerable<double> Jagged2DImageEnumerable(IList array, int minLength, int maxLength)
        {
            IList parent = array;
            int count = parent.Count;
            for (int j = 0; j < maxLength; ++j)
            {
                for (int i = 0; i < count; ++i)
                {
                    IList child = parent[i] as IList;
                    if (j > child.Count - 1) yield return Double.NaN;
                    else yield return Convert.ToDouble((parent[i] as IList)[j]);
                }
            }
        }
}

Related Tutorials