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