Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an anonymous type inherit from another type?

According to the MSDN documentation on the StringComparer.OrdinalIgnoreCase property:

The OrdinalIgnoreCase property actually returns an instance of an anonymous class derived from the StringComparer class.

Is this a feature I'm unfamiliar with—anonymous types with inheritance? Or by "anonymous class" did the author simply mean "internal class deriving from StringComparer, not visible to client code"?

like image 401
Dan Tao Avatar asked Nov 26 '10 17:11

Dan Tao


1 Answers

It's not an anonymous type in the normal C# meaning of the term.

It's just a type which is internal, so you don't know the name of it: you can't refer to the exact type within your code.

like image 106
Jon Skeet Avatar answered Oct 13 '22 19:10

Jon Skeet