First thing a programmer looks for is what kind of data types a programming languages has and how to use them. In this part, I will cover C# data types and how to use them in a program.
Basic Data TypesMost of the data type in c# are taken from C and C++. This tables lists data types, their description, and a sample example.
decimal
Types in C#
C# supports two kinds of types: value types and reference types.
Value Types- Value type objects direct contain the actual data in a variables. With value types, the variables each have their own copy of the data, and it is not possible for operations on one to affect the other.
int i = 10;
Reference Types- Reference type variables stores the reference of the actual data. With reference types, it is possible for two variables to reference the same object, and thus possible for operations on one variable to affect the object referenced by the other variable.
MyClass cls1 = new MyClass();
Data Type Conversions
C# supports two types of conversions. Implicit conversions and explicit conversions. Implicit conversions are direct conversion. For example:
int iVal = 34; long lVal = intValue;
Explicit conversions includes type casting. conversion. For example:
long lVal = 123456; int iVal = (int) lVal;