Delegate Example From C# In Depth Confusion
Posted
by ChloeRadshaw
on Stack Overflow
See other posts from Stack Overflow
or by ChloeRadshaw
Published on 2010-04-12T12:24:07Z
Indexed on
2010/04/12
12:33 UTC
Read the original article
Hit count: 143
c#
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
© Stack Overflow or respective owner