0
在我的代码中,我在for循环中获取对象的类型(Party对象),并获取特定属性“firstname”的属性信息。 Party []集合中的所有对象都返回相同的类型,所以我希望在while循环中只获取一次以外的类型,并且仍然需要能够从正确的聚会对象中获取属性“firstname”。 可以这样做吗?谢谢你的帮助。如何在运行时获取对象集合中的对象类型?
public List<Party> Parties { get; set; }
PropertyInfo info = null;
i = 1
do
{
foreach (Field field in TotalFields)
{
info = Parties[i - 1].GetType().GetProperty("firstname");
//some other code here
}
i++;
} while (i <= Parties.Count);
非常感谢。我想我现在明白了。 – Jyina 2011-04-12 18:09:16