I have an IList:
IList list = CallMyMethodToGetIList();
that I don't know the type I can get it
Type entityType = list[0].GetType();`
I would like to search this list with LINQ something like:
var itemFind = list.SingleOrDefault(MyCondition....);
Thank you for any help.
Simple:
IList list = MyIListMethod();
var item = list
.Cast<object>()
.SingleOrDefault(i => i is MyType);
or:
IList list = MyIListMethod();
var item = list
.Cast<object>()
.SingleOrDefault(i => i != null);
hope this help!
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