List<T> defines the Find(Predicate<T> match) method.
Predicate<T> is a delegate that can reference any method that matches its signature
bool Predicate(T param)
In your case, you call the Find method on the list of students List<Student> , so the Find method expects a function that matches the following signature:
bool MyFindMethod(Student param)
You can define such a method in your class as follows:
bool MyFindMethod(Student param) {
and pass it to your Find method as follows:
students.Find(MyFindMethod)
The method you use is small and simple, so the overhead of creating a method in your class is not worth the lambda expressions allowing you to very accurately define the same method.
s => s.Id == id
equivalent to:
bool AnonymousMethod(Student param) { return s.Id == id; }
The element on the left side of the operator => is the parameters that are passed to the method, and the elements on the right side of the operator => are the body of the method.
Note that the compiler is smart enough to understand that the parameter ( s in my example) is of type Student , so this need not be specified.
If you have a list of another type of EG
public class Customer { public string Name { get; set;} } public IList<Customer> customers = new List<Customer>();
then the compiler will infer that the parameter is of type Customer , not a student.
customers.Find(c => c.Name == name);
Note that the parameter can be named whatever you want, but it is usually stored in one letter so that the expression is concise.
If you understand all this, you will see that your code
students.Find(i => i.Id == id)
basically calls a method that takes Student as a parameter and evaluates it to see if it matches the criteria on the right side of the => operator. If the parameter matches the criteria (that is, if the students Id match the variable Id ), the expression will return true. This tells Find that it found a match, and this object will be returned.
I answered a similar question here that is related to WPF, but an example in a different context may help you understand.