A_N*_*lsi 58
这应该工作,
List<int> result = YourListObject.Select(o => o.FirstInteger).Distinct().ToList();
Run Code Online (Sandbox Code Playgroud)
Jas*_*ans 10
尝试:
var g = collection.Select(i => i.Property1).Distinct();
你能发布一些源代码,以便我们能给你一个更好的例子吗?
编辑:
在我的示例中,我有一个collection
包含您的类的许多实例的集合.然后我Property1
从每个类中选择,过滤到该属性的不同值.
我发现这对我来说很有用,也很适合我.
var distinctNames = (from d in YourList select d).Distinct();
Run Code Online (Sandbox Code Playgroud)
希望这对像我这样在SO中搜索细节的人有用.