Skip to main content

What is an anonymous type in C#?

Junior C#
Quick Answer An anonymous type lets you create a throwaway object without defining a class: var p = new { Name = "John", Age = 25 }. The compiler generates the class with read-only properties behind the scenes. Used mostly in LINQ projections where you need a temporary data shape.

Answer

An anonymous type is an object created without defining a class.

The compiler generates a temporary type with read-only properties.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice