You may have noticed already that some variables can have a default value of null, while others can’t. Well, that is not entirely true. Nullable variable types refers to exactly this situation: creating a specific wrapper around the value types (types that cannot be null), that allow them to store data with a null value.… Read more
Archive for 2016
Nullable variable types
Thursday, December 29th, 2016Object variable type
Thursday, December 29th, 2016Object variable type is a special type, the parent of all other types in the .NET Framework. It can accept values from any other type in C#, and we declare it using the word object.
In the following example you can see how we can assign any type to an object variable type:
Var keyword
Thursday, December 29th, 2016In the previous lessons, I’ve said that when declaring a variable, we are required to indicate the compiler the type of the variable and its name. These kind of variables are called explicitly typed variables:
1 |
int integerVariable = 123; // explicitly typed variable |
However, this is not entirely true.… Read more
String variable type
Thursday, December 29th, 2016If you remember the lesson about char variable type, you know that a char can only store a single character. And you also remember that for storing more than a single character, I said you will be using the string variable type.… Read more
Boolean variable type
Thursday, December 29th, 2016The Boolean variable type is probably the easiest type of variable. It doesn’t have a “maximum range”, it can’t produce “overflow” exceptions, it’s not affected by precision, etc. In fact, Boolean variable type can only have two values: true or false. … Read more
Real types error calculations
Thursday, December 29th, 2016In calculations with real floating-point data types it is possible to observe strange behavior, because during the representation of a given real number it often happens to lose accuracy. The reason for this is the inability of some real numbers to be represented exactly as a sum of negative powers of the number 2.… Read more
Overflow exception
Wednesday, December 28th, 2016Type modifiers
Tuesday, December 27th, 2016Decimal variable type
Tuesday, December 27th, 2016Decimal variable type, unlike float and double, which are binary point types, is a floating decimal point type. It can store 128 bits, and compared to the float or double types, it has more precision and a smaller range. This makes it best suitable for financial calculations and any situations where precision is crucial.… Read more
Double variable type
Tuesday, December 27th, 2016C# compiler allocates 64 bits (8 bytes) to store a double variable type. For reference, a double variable type can keep values with a precision of 14 or 15 digits, in the interval between 1.7E-308 and 1.7E+308.
You should know that the float and the double variable types are floating binary point types.… Read more