我有这个类如何从列表中选择不同的项目
class Test
{
public string Property { get; set; }
public string ID { get; set; }
public List<string> MyProperty { get; set; }
}
和我创建它的
List<Test> t = new List<Test>() {
new Test() {
ID = "1",
Property = "2"
},
new Test() {
ID = "2",
Property = "3"
},
new Test() {
ID = "2",
Property = "5"
}
};
我想有具有由ID filteried不同的元素列表中的实例,并也公开List MyProperty {get;组; }应该填充公共字符串Property {get;组; }数据。
所以最终的结果应该是
List<Test> = {
1. ID = "1",List<MyProperty> = "2"
2. ID = "2",List<MyProperty> = "2"
};
'名单'你说'名单 MyPropertyList'?您不能使用变量的名称作为类型。 –