我有這個類如何從列表中選擇不同的項目
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'?您不能使用變量的名稱作爲類型。 –