I have a Layer collection which contains a Content object as a property. How do I cast this Content to its original object to get its property in LINQ statement?
For example:
var item = Layers.FirstOfDefault(x =>(PushPin)x.Content.Description == "xyz");
In this case Content is of PushPin object type and I want to compare its Description property to xyz
If Content can be something other than PushPin then you will need something along the lines of
var item = Layers.FirstOrDefault(x => x.Content is PushPin && ((PushPin)x.Content).Description == "xyz");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With