Is it correct to assume that if for instance I would write
sizeof(int)
then it would return the number of bytes a variable can support
and on the other hand the ranges are the integral range value of the variable can be assigned to?
Is it correct to assume that if for instance I would write
sizeof(int)
then it would return the number of bytes a variable can support
and on the other hand the ranges are the integral range value of the variable can be assigned to?
That sounds about right - the sizeof
operator returns the number of bytes it would take to hold a value of the given data type.
Instead of trying to derive the integral range from the result, you should use the MaxValue
and MinValue
properties of that integral data type like this:
int.MaxValue
int.MinValue