I have a general list of values. I want to check if an identifier exists in this general list.
What is the easiest way to do this?
Example
List<someCustomObject> mylist = GetCustomObjectList(); int idToCheckFor = 12;
I want to see if 12 exists in any of the user objects in the list by checking each someCustomObject.Id = idToCheckFor
If a match is found, Iām good to go, and my method will return bool true. I'm just trying to find out if there is an easy way, rather than iterating over each item in the list to see if idToCheckFor == someCustomObject.id and setting the variable to true if a match is found. I am sure there will be a better way to do this.
source share