I have a custom class, with a property ID. We can name this class A, and the property ID.
I have an observable collection of A, and I would like to get the firstOrDefault to know if an object exists with a determined ID. Soy I do the following:
myObersableCollection.FirstOrDefault(a=>a.ID==2)
But I get the following error: it is not possible to convert implicitly A into bool.
What am I doing wrong?
Thanks.
Daimroc.
FirstOrDefault()returns a matching object, not a boolean.If you just want to check whether there is a matching object, call
.Any()instead.