First Or Default from ICollectionView - CSharp System.Collections

CSharp examples for System.Collections:ICollection

Description

First Or Default from ICollectionView

Demo Code


using System.ComponentModel;

public class Main{
    public static T FirstOrDefault<T>(this ICollectionView view)
      {//from  ww  w .j av  a2  s  .  co m
         var enumerator = view.GetEnumerator();
         if (enumerator.MoveNext())
            return (T)enumerator.Current;
         else
            return default(T);
      }
}

Related Tutorials