C# Data types


C# Data types

C# Data types The factors in C#, are classified into the accompanying kinds −

  1. Value Types
  2. Reference types
  3. Pointer types
  4. 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

Reference Type

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.
Object Type

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.

object obj;

obj = 100;/this is boxing

Dynamic Type

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;

For instance,

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.

String Type

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.

For instance,

String str = “Instructional exercises Point”;

A @quoted string exacting looks as follows −

@”Tutorials Point”;

The client characterized reference types are: class, interface, or agent. We will examine these sorts in the later part.

Pointer Type

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 −

type* identifier;

For instance,

char* cptr;

int* iptr;

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories

%d bloggers like this: