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 © 2017  Terms of Use | Home