This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Saturday, March 8, 2025

What are Anonymous types in C#

 What are Anonymous types in C#

Here, subject is an anonymous type variable containing two properties: Name and Code.

You can see we have used a new operator to create an anonymous type.


What is an anonymous type in C#?

Anonymous types are class types that derive directly from object , and that cannot be cast to any type except object . The compiler provides a name for each anonymous type, although your application cannot access it.


C# Nested Anonymous Type

In C#, we can also create an anonymous type inside the property of another anonymous type. This is called nested anonymous type. 

No comments:

Post a Comment