IList添加Find(delegate)方法
來源:易賢網 閱讀:2481 次 日期:2014-09-11 15:50:24
溫馨提示:易賢網小編為您整理了“IList添加Find(delegate)方法”,方便廣大網友查閱!

/// <summary>

/// Find data in IList<T>

/// </summary>

public static T Find<T>(System.Collections.Generic.IList<T> list, Predicate<T> match)

{

if (list != null && list.Count > 0)

{

foreach (T obj in list)

{

if (match(obj))

{

return obj;

}

}

}

return default(T);

}

IList<>居然沒有這個方法了,只好自己參考List<>.Find寫了一個.

Utils.Find(list, delegate(Test item){

return Item.Id == testId;

}

更多信息請查看IT技術專欄

更多信息請查看辦公軟件使用
易賢網手機網站地址:IList添加Find(delegate)方法
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網