CSharp examples for System.Collections:ICollection
Get first item in a collection
using System.Text; using System.Collections.Generic; using System;/* www.jav a 2 s . com*/ public class Main{ /// <summary> /// Get first item in a collection /// </summary> /// <typeparam name="T"></typeparam> /// <param name="collection"></param> /// <returns></returns> public static T First<T>(ICollection<T> collection) { foreach (T item in collection) return item; return default(T); } }