Dynamic Binding in C#

In Dynamic binding, the compiler will not do type checking at compile time. At run time, 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.


public dynamic GetAnonymousType() {
   return new {
      StudentName = "Tom",
      Subject = "Java",

Above, the method is set to be dynamic, that would means the compiler won’t do type checking at compile time.

public dynamic GetAnonymousType() {

Updated on: 23-Jun-2020


Kickstart Your Career

Get certified by completing the course

Get Started