What is an anonymous type in LINQ, and how is it used?

  • It is a predefined type in LINQ used for query expressions.
  • It is a type created dynamically at runtime to encapsulate data.
  • It is a type that can only be used within LINQ queries.
  • It is a type with no name used for declaring variables.
An anonymous type in LINQ is a type created dynamically at runtime to encapsulate data. It allows you to define a new type without explicitly declaring a class or struct. Anonymous types are typically used to store the results of query expressions or to project data into a new shape. They are convenient for one-time use cases where defining a formal type would be unnecessary overhead. However, they cannot be used outside of the method or scope where they are defined.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *