+ 1
Why int is a struct in C#?
Why int is a struct in C#?
3 Réponses
+ 3
We know that int has a maximum and a minimum value, on the other hand though a string can grow dynamically, it doesn't have an exact size like int has, I'm gonna elaborate this in another comment.
+ 3
So the size of an unassigned integer (uint) by default is 32 bit. That literally means 32 pieces of the number 1 next to each other in binary: 111111111111111111111111111111111
This is 4294967295 in binary (2^32-1).
Why minus one? Because we don't count from one but from zero, thus we don't actually count zero.
+ 3
So eventually uint can store 2^32 values but the max value is 2^32-1 because we start counting from zero.