Ticker

6/recent/ticker-posts

C# (C Sharp) - Data Types

C# (C Sharp) - Data Types 

The variables in C#, are categorized into the following types: 

  • Value types
  • Reference types
  • Pointer types

Value type 

  • Variables can be assigned a value directly. They are derived from the class System.ValueType. 
  • The value types directly contain data. Some examples are int, char, and float, which stores numbers, alphabets, and floating point numbers, respectively. When you declare an int type, the system allocates memory to store the value. 

Reference Type 

  • The reference types do not contain the actual data stored in a variable, but they contain a reference to the variables.
  • In other words, they refer to a memory location. Using multiple variables, the reference types can refer to a memory location. If the data in the memory location is changed by one of the variables, the other variable automatically reflects this change in value. Example of built-in reference types are: object, dynamic, and string. 

Pointer Type

  • Pointer type variables store the memory address of another type. Pointers in C# have the same capabilities as the pointers in C or C++. 
  • Syntax for declaring a pointer type is − type* identifier; 

For example: 

char* cptr; 

int* iptr; 

"data types in c sharp"

"data types in c# sharp"

"data types in c# with examples"

"data types in c# pdf"

"user-defined data types in c#"

"c# data types list"

"decimal data type in c#"