Why does IPAddress
constructor take Int64
instead of UInt32
? According to Reflector the address is stored as an Int64
internally (m_Address
) and the constructor validates it to be within the range valid for UInt32
. So I'm just curious why it uses Int64
and not UInt32
.
And before anyone says IPv6.. IPv6 is bigger than Int64
and is stored as an array of UInt16
. The Int64
constructor is only used to generate IPv4 addresses.
Probably because in the Common Language Specification (CLS) of the Common Language Infrastructure (CLI) standard, unsigned types are not required to be supported by a language so they used the smallest signed type that will hold all the possible unsigned values.
The .NET Framework class library includes types that correspond to the primitive data types that compilers use. Of these types, the following are CLS-compliant:
Byte
,Int16
,Int32
,Int64
,Single
,Double
,Boolean
,Char
,Decimal
,IntPtr
, andString
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With