Hi, I am new in c sharp programming language, I want to know how Anonymous Classes work in C#?
Can anyone help me out in this, please?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
maria josephPosted Jun 27, 2017, 3:31 AM
Anonymous, as it can be understood from the name is undesignated or unspecified interim data type whose properties can be read only but it couldn’t manipulated. The scope of anonymous type is always local to the method where it is declared. Points to be noted in case of anonymous types:
1. Defined using the keyword new.
2. They are the only reference type.
3. The implicitly typed variable-var is used to hold an anonymous type.
Restrictions of Anonymous Classes :
1.Anonymous classes can contain only public fields.
2.Anonymous class's fields must all be initialized.
3.Anonymous class members are never static.
4.Anonymous class cannot specify any methods.
Anonymous methods is an undesignated method which uses the delegate keyword followed by the name of the required method and its body. They can be easily used to assign handlers to events. We can declare the methods without parameters or use parameters to declare them.
Manikandan MurugesanPosted Jun 26, 2017, 2:22 AM
Vivek KumarPosted Jun 25, 2017, 6:45 PM
Rajkiran SwainPosted Jun 24, 2017, 1:17 PM
Abhilash J APosted Jun 23, 2017, 12:22 PM
Nilesh ShahPosted Jun 23, 2017, 11:07 AM