Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialawdeeoh
358 Pointsdelete
.
1 Answer
Steven Parker
231,271 PointsThe easiest way to choose a storage type is from the value range it needs to handle, and if it needs to hold only positive values or both positive and negative. This table shows you the value ranges for each type along with the storage size in bits:
C# type/keyword | Range | Size |
---|---|---|
char or sbyte | -128 to 127 | Signed 8-bit integer |
byte | 0 to 255 | Unsigned 8-bit integer |
short | -32,768 to 32,767 | Signed 16-bit integer |
ushort | 0 to 65,535 | Unsigned 16-bit integer |
int | -2,147,483,648 to 2,147,483,647 | Signed 32-bit integer |
uint | 0 to 4,294,967,295 | Unsigned 32-bit integer |
long | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | Signed 64-bit integer |
ulong | 0 to 18,446,744,073,709,551,615 | Unsigned 64-bit integer |
For reference, this information can be found in the online Microsoft Documention.