gpt4 book ai didi

c# - ObservableCollection.Contains(MyCustomObject.SomeProperty)

转载 作者:太空宇宙 更新时间:2023-11-03 22:19:56 29 4
gpt4 key购买 nike

如何扩展(或重载)包含集合中某些自定义属性的方法?

我希望该委托(delegate)将对象与其属性进行比较,如果存在具有相同属性值的对象则返回 true。

最佳答案

return myCollection.Any(myCustomObject => myCustomObject.SomeProperty.Equals(valueToFind));

关于c# - ObservableCollection<MyCustomClass>.Contains(MyCustomObject.SomeProperty),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3508880/

29 4 0