I have a list of lists as below:
List<List <T> > userList
Class T { string uniqueidentifier, string param2, int param2}
I have a uniqueidentifier and i need to find the element T in the list that has the same ‘uniqueidentifier’ value.
I can do it using two ‘foreach’ loops. This does not seem to be nice way doing things. I guess there should be some inbuilt method like ‘Find’ that does the same thing and is highly optimized.
Findis not optimized at all — it performs a linear search, since that’s the only thing that makes sense on an unsorted list. If you are looking at a nicer way to write it, you could use LINQ: