+ 1

What is the difference between Convert.ToInt32 and Convert.ToInt64???

14th Aug 2020, 4:03 PM
Emmanuel Peter
Emmanuel Peter - avatar
2 ответов
+ 4
Convert.ToInt32() will return a 32 bit signed integer (Int32). It can only properly hold numbers in a range that can be held in 32 bits. It thusly has a size of 4 bytes of memory. https://docs.microsoft.com/en-us/dotnet/api/system.convert.toint32?view=netcore-3.1 Likewise, with Convert.ToInt64 it will return a 64 bit signed integer (Int64) with a size of 8 bytes of memory. https://docs.microsoft.com/en-us/dotnet/api/System.Convert.ToInt64?view=netcore-3.1
14th Aug 2020, 4:26 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
I don't know, but it would make sense that int32 is an integer requiring 4 bytes of memory and int64 requiring 8 bytes of memory. Thus int32 would be limited to a value between (-256^4/2) and (256^4/2-1). And int64 would be limited to a value between (-256^8/2) and (256^8/2-1).
14th Aug 2020, 4:13 PM
Seb TheS
Seb TheS - avatar