Summary
In today's lesson, you learned how the computer stores information. You focused on the data types that store data by value, including int, uint, long, ulong, bool, char, short, ushort, float, double, decimal, byte, and ubyte. In addition to learning about the data types, you learned how to name and create variables. You also learned the basics of setting values in these variables, including the use of literals. Table 3.4 lists the data types and information about them.
Table 3.4 C# Data Types
C# Data Type |
NET Data Type |
Size in Bytes |
Low Value |
High Value |
sbyte |
System.Sbyte |
1 |
-128 |
127 |
byte |
System.Byte |
1 |
0 |
255 |
short |
System.Int16 |
2 |
-32,768 |
32,767 |
ushort |
System.UInt16 |
2 |
0 |
65,535 |
int |
System.Int32 |
4 |
-2,147,483,648 |
2,147,483,647 |
uint |
System.UInt32 |
4 |
0 |
4,294,967,295 |
long |
System.Int64 |
8 |
9,223,372,036, 854,775,808 |
9,223,372,036, 854,775,807 |
ulong |
System.UInt64 |
8 |
0 |
18,446,744,073 709,551,615 |
char |
System.Char |
2 |
0 |
65,535 |
float |
System.Single |
4 |
1.5 x 10-45 |
3.4 x 1038 |
double |
System.Double |
8 |
5.0 x 10-324 |
1.7 x 1010308 |
bool |
System.Boolean |
1 |
false (0) |
true (1) |
decimal |
System.Decimal |
16 |
1.0 x 10-28 |
approx. 7.9 x 1028 |