What is anonymous types in c#?
c#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dipankar BiswasRank #992 · 2K reputationPosted Oct 26, 2014, 7:30 PM EDT
Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to explicitly define a type first. The type name is generated by the compiler and is not available at the source code level. The type of each property is inferred by the compiler.
http://www.c-sharpcorner.com/UploadFile/ff2f08/anonymous-types-in-C-Sharp/
Ajay YadavRank #313 · 8.1K reputationPosted Oct 27, 2014, 6:29 PM EDT
Sometime a function is used with delegate. It never called directly as a stand-alone method. Anonymous methods are nameless method. They prevents creating a separate methods unnecessarily, which more cleaner and convenient approach.
Define an anonymous method with the delegate keyword and a nameless function body. This code assigns an anonymous method to delegate. The anonymous method must not have a signature. The signature and return type is inferred from the delegate type. For example if the delegate has three parameters and return a double type, then the anonymous method would also have the same signature