A simple way to think of an anonymous method, albeit not a pure definition, is a method that you want to use once and move on. They're called anonymous because the aren't named methods. Lambdas, in C#, are an extremely powerful way of linking commonly used methods based on your individual objects.
What your code is doing, in one line would take many lines to write out unique methods based on every one of your classes.
To break down what your code is doing dot-by-dot:
var validRatings = settings.grossAlphas.Select(ga => ga.fundRating).ToList();
grossAlphas.Select(...)
: is walking through your enumeration (List, Array, etc...) object by object and aggregating them according to the parameters you supply inside the .Select(...)
.
ga => ga.fundRating
: you are saying that you want to aggrigate ONLY the fundRating
attribute from each object.
.ToList()
: is making your enumeration into a List<int>()
.
This saves you from writing a List<int> GetFundRatings()
for a single time you need to use a list of FundRatings.
Also see:
What is a lambda (function)?
C# Lambda expressions: Why should I use them?