C# Data Types
Data types specify the size and type of values that can be stored. Every variable in C# is associated with a data type. C# is a rich language in its data types. In C#, there are mainly two types of data types:
In C#, Value Types are stored on the stack and when a value of variable is assigned to another variable, the value is actually copied. It means that two identical copies of the value are available in memory. There are two types of Value types namely:
Predefined Types are also known as Simple Types. It is divided into three categories:
Numeric Types: Numeric Types are three types :
Integral Type: Integral Types can hold whole numbers such as 123, -50 and 2540. the size of the values that can be stored depends on the integral data type we choose.
Floating-Point Type: Floating-Point Types can hold whole numbers containing fractional parts such as- 25.54 and -3.14.
Decimal Type: The decimal type is a high precision. The 128-bit data type that is designed for use in financial and monetary calculations. It can store values in the range 1.0×10-28 to 7.9×1028 with 28 significant digits.
Boolean Types: Boolean Types is used when we want to test a particular condition during the execution of the program. There are only two values that a Boolean type can take : true or false. Boolean type is denoted by the keyword bool and it uses only one bit of storage.
Character Types: C# provides a character data type that is called char. The char type assumes a size of two bytes but it can hold only a single character.