How to get range of data types in c#?
How to get range of data types in c s开发者_Python百科harp .net ? For example if I wish to get range of uint datatype, how can I get it through code ?
Please see this sample reference -->
UInt64.MinValue Field - Represents the smallest possible value of UInt64. This field is constant. MSDN Link - http://msdn.microsoft.com/en-us/library/system.uint64.minvalue.aspx
UInt64.MaxValue Field - Represents the largest possible value of UInt64. This field is constant. MSDN Link - http://msdn.microsoft.com/en-us/library/system.uint64.maxvalue.aspx
No standard, sorry.
But they all implement IIRC MinValue and MaxValue, so you could use reflect to get those static items.
If I understand your question correctly, you can use:
uint.MinValue
and
uint.MaxValue
If you mean min/max values for numeric types they are usually defined as constants on that type. Eg.: int.MaxValue;
精彩评论