This Angular tutorial helps you get started with Angular quickly and effectively through many practical examples.

C# - DataTypes

C# is a strongly-typed language. It means we must declare the type of a variable. C# has several built-in data types that can be used to store different types of values. These data types can be broadly classified into the following categories. They are Value Types , Reference Types and Pointer Types . The Value Types store the data while the Reference Types store references to the actual data. Pointer Types variable use only in unsafe mode. The Value Types derived from System.ValueType and the Reference Types derived from System.Object .

C# Data Types

Types of C# DataTypes

  1. Value types
  2. Reference types
  3. Pointer types

1. Value types

These are data types that store their value directly in memory. They are typically used for simple types of data like numbers, bool and characters.

Data TypeDescription
int It represents a 32-bit signed integer
long It represents a 64-bit signed integer
floatIt stores a single-precision floating-point number.
double It represents a double-precision floating-point number
char It represents a single Unicode character
bool It represents a Boolean value (true or false)
byteIt represents an 8-bit unsigned integer
shortIt represents a 16-bit signed integer

2. Reference types

These are data types that store a reference to an object in memory. They are typically used for more complex types of data like strings and arrays.


Data TypeDescription
string It represents a sequence of Unicode characters
objectIt represents a reference to any object
dynamicIt represents a value that can be any type at runtime
classIt a user-defined reference type that can contain data and methods.

3. Pointer types

These are data types that store a memory address. They are used in low-level programming and are not commonly used in C#.

Following is the syntax of declaring the pointer type in the c# programming language.

  1. int*: a pointer to an integer
  2. char*: a pointer to a character.

Prev Next

Top Articles

  1. Why use C#
  2. How to use comment in C#
  3. How to use variables in C#
  4. How to use keywords in C#