Csharp Data Type List

C# is a language that is strongly typed. Csharp Data Type must provide the type of a variable, such as an integer, float, decimal, text, etc., to indicate the kind of values it will hold. A data type specifies the size and type of variable values.

Use the proper data type for the associated variable to prevent errors, save time and memory, and improve your code's readability and maintainability. The most typical sorts of data are three, and they are the Value Data Type: short, int, char, float, double, etc., the Pointer Data Type: Pointers, and the Reference Data Type: String, class, object, and interface.

The Value Csharp Data Type

Any data type that stores a data value in its memory space is a value type. In other words, these data types' variables hold values. Take the integer variable int I = 100, for instance.

In the memory space designated for variable I, the system keeps 100. The following graphic demonstrates how 100 is saved for the character I at some fictitious position in memory (0x239110):

Value data types include character types, decimal types, and floating-point numbers types, and the C# programming language also has both signed and unsigned literals types. 

Character Types

The character types indicate either a UTF-16 code unit or a 16-bit Unicode character.

Decimal Types

The decimal data type is a 128-bit data type commonly used in financial and monetary calculations. It has a precision of 28–29 digits. Use the suffix m or M to set a decimal variable to its initial value. For example, decimal x = 300.5m; If the suffix m or M won't work, it's considered double.

Floating-point Numbers Types

Floating point data has two types that support the decimal point, and they are:

Double:

It is a double-precision floating-point type with 64 bits. It has a precision of 14 to 15. Use the prefix d or D to initialize a double variable. However, since floating data types by default are of the double type, using the suffix is not required.

Float:

It is a single-precision 32-bit floating point type. Precision is 7 digits. Use the suffix f or F to initialize a float variable. For example, float x = 3.5F;. The word is treated as double if the suffix F or f cannot be used.

Signed and Unsigned Literals: 

Eight integral types support signed or unsigned 8-bit, 16-bit, 32-bit, and 64-bit numbers.

The C# programming language has two types of value data types:

Predefined Data Types - such as Integer, Boolean, Float, etc.

And User-defined Data Types - such as Structure, Enumerations, and so on.

The memory size of data types can vary depending on whether the operating system is 32 or 64 bits.

Pointer Csharp Data Type

A pointer is a variable of C# that points to a value's address. It is also known as a locator or indicator. The variable value's memory address will be stored in the Pointer Data Types.

We have two symbols to get the pointer details: an ampersand (&) and an asterisk (*).

The ampersand (&): It is referred to as an Address Operator. It is used to determine a variable's address.

The asterisk (*) is also referred to as the Indirection Operator. It is used to get the address's value.

Reference Data Type

Because the variable value will not be stored directly in memory, the Reference Data Types contain the memory address of the variable value. Object and String are the built-in reference types.

Object: 

In C#, all types, both predefined and user-defined, as well as reference and value types, derive directly or indirectly from the object. It is the base class for all data types in C#. Type conversion is required before assigning values. Boxing occurs when a value-type variable is converted to an object. Unboxing occurs when an object variable is converted to a value type. The system is the name of its type. Object.

For instance

String

System String is the type name for a sequence of Unicode characters. As a result, string and String are interchangeable.

These are what you need to know about C# variables. Knowing all these would help you as a beginner in C# programming, and if you imbibe all that has been said, you will have a seamless sojourn as a C# programmer. 

For More blogs visit