|The built-in data type in C# is called primitive data types. Here we are giving you the range of most commonly used primitive data types in C#.
|Notes: ~ The value of 216 is 32,768;
‡ The value of 231 is 2,147,483,648;
§ The value of 263 is 9,223,372,036,854,775,808;
|The Integer Type
|The C# integer type break into two types – signed and unsigned Signed value type has contained positive and negative values while unsigned value type has contained only positive values.
|The sbyte and byte type
|Both sbyte and byte type represent a single byte or character. Bytes can be use to store very small numbers, such as day of the month. The byte values are to be used for flags, single values, and object serialization. C# has no true concept of pointers, so bytes are often used to index into a string and write it out.
|Note: A byte value is restricted to only 8 bits of precision; a long string could overflow the index.
|The short value
|In real application, the short value is used to represent small integers. The signed short values can have the range between +32767 to -32767 with zero. The unsigned short values can have the range from 0 to 65535.
|The Floating-Point Type
|In C#, floating point numbers break into two types– single and double floats. Single floats can hold the values up to 1038, the double floats can hold the values up to 10308.
|The Boolean and Decimal Type
|The other two important value types are Boolean type and Decimal type. Boolean are simply contains true or false values. In C#, it can’t be assigned to any other type and it can’t be used in any sort of computation. The result of an expression in C# is not a Boolean expression, unless you specifically assign it as true or false. The given example doesn’t work in C# because you can use Boolean values in only Boolean expression:
|for the above example, you must write like this:
|These two code pieces are functionally equal in C++ and Java, but don’t do the same in C#.
|The Decimal data type, is equivalent to a long integer that behaves as if it were a floating –point number. Decimal values are intended to be used for economic computation or other calculations in which transaction beyond the decimal point is not desired behavior.
|Default values of datatype