C# Data types
C# Data types The factors in C#, are classified into the accompanying kinds −
- Value Types
- Reference types
- Pointer types
- Value Type
Value type factors can be allocated a worth legitimately. They are gotten from the class System.ValueType.
The value kinds legitimately contain information. A few models are int, singe, and buoy, which stores numbers, letters in order, and gliding point numbers, separately. At the point when you pronounce an int type, the framework designates memory to store the worth.
The accompanying table records the accessible worth sorts in C# 2010
The reference types don’t contain the genuine information put away in a variable, yet they contain a reference to the factors.
At the end of the day, they allude to a memory area. Utilizing various factors, the reference types can allude to a memory area. In the event that the information in the memory area is changed by one of the factors, the other variable naturally mirrors this adjustment in esteem. The case of inherent reference types is article, dynamic, and string.
The Object Type is a definitive base class for all information types in C# Common Type System (CTS). The article is an assumed name for System. Object class. The item types can be appointed estimations of some other sorts, esteem types, reference types, predefined, or client characterized types. Notwithstanding, before doling our qualities, it needs type change.
At the point when a worth sort is changed over to question type, it is called boxing, and then again, when an article type is changed over to a worth kind, it is called unpacking.
obj = 100;/this is boxing
You can store any sort of significant worth in the dynamic information type variable. Type checking for these kinds of factors happens at run-time.
Language structure for announcing a powerful kind is −
dynamic <variable_name> = esteem;
dynamic d = 20;
Dynamic sorts are like item types aside from that type checking for object type factors happens at the aggregate time, while that for the dynamic kind factors happens at run time.
The String Type permits you to dole out any string qualities to a variable. The string type is a nom de plume for the System. String class. It is gotten from object type. The incentive for a string type can be appointed utilizing string literals in two structures: cited and @quoted.
String str = “Instructional exercises Point”;
A @quoted string exacting looks as follows −
The client characterized reference types are: class, interface, or agent. We will examine these sorts in the later part.
Pointer type factors store the memory address of another sort. Pointers in C# have indistinguishable capacities from the pointers in C or C++.
Language structure for proclaiming a pointer type is −