【发布时间】:2013-10-22 13:30:39
【问题描述】:
我有课
class Person {
int Age;
string Name;
}
List<Person> pList = new List<Person>();
pList.Exists(p=> p.Name == "testName"); <-- need an alternative for this.
我正在使用 .net 3.0。
因此我无权使用getFirstOrDefault 方法。
Exists 方法为空值抛出异常,但我不想中断我的程序流程;还有其他选择吗?
我也没有 Any 或 Linq 可用。
【问题讨论】:
-
你有什么?你有数组、列表、
IEnumerable还是什么?那个系列里面有什么?你想用那个集合做什么?显示一些示例输入/输出。
标签: c# collections .net-3.0