A variable is nothing more than a name that our programs can change for a storage place. Each variable in C# has a specific type that determines the memory size and layout of the variable by the range and the number of operations to be applied to that variable that can be saved inside that memory.
Type | Example |
---|---|
Integral types | byte, sbyte, ushort, short, uint, int, ulong, long, and char |
Floating point types | double and float |
Decimal types | decimal |
Boolean types | true / false values, as assigned |
Nullable types | Nullable types |
C# also allows you to define other variable value types such as enum and variables references such as a class included in the next chapters.
The C# variable default syntax is –
< data_type > < variable_list >;
In this case, the data type must include a valid C# data type, including the char, the int, the float, and the double or any user-defined data type.
Variables containing an equal signal followed by a constant expression are initialized (attributed value). The main way to initialize is —
variable_name = value;
In their declaration, variables may be initialised. The initializer is a symbol that is equal to a constant phrase as –
< data_type > < variable_name > = value;
C# contains two types of terms −
Variables are values and can be found on the left of a task. Numeric literals are value values and cannot be allocated on the left.
Programs can change for a storage place. Each variable in C# has a specific type that determines the memory size and layout of the variable by the range and the number of operations to be applied to that variable that can be saved inside that memory.
|