C# dynamic

dynamic is a static data type which will bypass the type check during compile time. However, if the dynamic represented data type has invalid operations, it will cause errors at run time.

public int add(int a,int b)
return a + b;
int res = add(3,5); //OK
dynamic res2 = add(3,5); //OK, correct
int i = res2 + 4; //OK, correct
string str = res2 + " is good"; //OK, Error at run time

endmemo.com © 2024  | Terms of Use | Privacy | Home