【发布时间】:2010-03-05 20:08:38
【问题描述】:
我基本上想在代码中做到这一点:
PersonList myPersonList;
//populate myPersonList here, not shown
Foreach (Person myPerson in myPersonList)
{
...
}
类声明
public class PersonList
{
public List<Person> myIntenalList;
Person CustomFunction()
{...}
}
那么如何在我的类中公开“myInternalList”作为 Foreach 语句可以使用的默认值呢?或者我可以吗?原因是我目前有大约 50 个类正在使用 GenericCollection,我想迁移到泛型,但不想重写很多。
【问题讨论】:
-
“默认值”是什么意思? C# 没有像 VB 这样的默认属性。