C# cast

When convert a numeric data type, e.g. double to int, or convert a base class to its derived class, the casts are needed.

double d = 23;
int i = (int)d;

If you convert a smaller integral to larger integral, or from derived class to base class, no casts are needed.
int i=23;
double d = i;

endmemo.com © 2017  Terms of Use | Home