The integer data types we can use in C#, along with the space they occupy in memory and the allowed range of values that they can store, are:
Type Name | Size (bytes) | Range of accepted values |
sbyte | 1 | -128 to 127 |
byte | 1 | 0 to 255 |
short | 2 | -32768 to 32767 |
ushort | 2 | 0 to 65535 |
int | 4 | -2147483648 to 2147483647 |
uint | 4 | 0 to 4294967295 |
long | 8 | -9223372036854775808 to 9223372036854775807 |
ulong | 8 | 0 to 18446744073709551615 |
As shown in this table, the best choice to store a person's age would be a "byte", which allows values from 0 255, and needs 3 bytes less than an "int".
No comments:
Post a Comment