CSharp examples for System.Collections.Generic:IEnumerable
Try Get from IEnumerable by Predicate
using System.Collections.Generic; using System.Collections; using System;// w ww .j a va 2s.c om public class Main{ public static bool TryGet<T>(IEnumerable list, Predicate<T> match, out T result) where T : class { foreach (T item in list) { if (match(item)) { result = item; return true; } } result = null; return false; } }