CSharp examples for System.Collections.Generic:IEnumerable
Get Element Or Default from IEnumerable by index
using System.Collections.Generic; using System.Collections; using System;/*from w w w. jav a 2 s . com*/ public class Main{ public static T GetElementOrDefault<T>(IEnumerable<T> collection, int at) { int idx = 0; foreach (T obj in collection) { if (idx == at) return obj; idx++; } return default(T); } }