- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is dynamic binding in C#?
In Dynamic binding, the compiler will not do type checking at compile time. At runtime, the checking is done.
Use it to avoid the restriction of anonymous types to one method. This is only because the type name is visible only to the compiler; therefore, you cannot declare it as the return value of a method.
Let us see an example −
public dynamic GetAnonymousType() { return new { StudentName = "Jack", Subject = "Maths", }; }
Above, the method is set to be dynamic, that would mean the compiler won’t do type checking at compile time −
public dynamic GetAnonymousType() {}
Advertisements