Delegate Example From C# In Depth Confusion
- by ChloeRadshaw
I am looking at this example:
List<Product> products = Product. GetSampleProducts() ;
products.Sort(
(first, second) => first.Name.CompareTo(second. Name)
) ;
foreach (Product product in products)
{
Console. WriteLine(product) ;
}
What function is actually called in the API when you do that? Does the compiler create a class which implemnents the IComparer interface?
I thought delegates were anonymous methods - Here it seems to be an anonymous interface implementation which is casuing confusion