I have Array of objects SomeObjects[] objects. This ‘objects’ may contain type of ‘Employee’, ‘Customer’ or something else. I wanted to write a linq query if ‘objects’ contain type of ‘Employee’ and if his name (Employee.Name) is ‘John’, I want to get the employeeid.
Is it possible?
Yes. You can use the safe cast operator
asoperator in your query to find objects of a specific type and have them cast to that type: