Skip to content

EN CSharp Types

Codex edited this page Oct 11, 2026 · 2 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

All built-in types

Manual C# · Examples UO

Type Destination
bool Boolean
byte, sbyte, short, ushort Small integers
int, uint, long, ulong Signed and unsigned integers
nint, nuint Integers the size of a process pointer
float, double Floating point numbers
decimal Decimal calculations
char Code unit UTF-16
string Immutable text
object Common base type
dynamic Linking Operations at Runtime

Value types include numbers, bool, char, structures, and enumerations. Classes, arrays, strings, interfaces, and delegates are reference types. Assigning to a structure copies its value; reference assignment can leave two variables with one object.

Simple example (Example.cs)

Save this example separately as Example.cs. Run it independently of the other examples on this page.

Example.cs:

// PROJECT-EXAMPLE
int count = 3;
string name = "Ore";
bool ready = true;
System.Console.WriteLine($"{name}:{count}:{ready}");

Result:

Ore:3:True
int hp = 50;
double fraction = hp / 100.0;
decimal price = 12.50m;
string text = $"HP={hp}, fraction={fraction:F2}, price={price}";
UO.Print(text);

var infers the type from the initial expression; it is not a separate dynamic type. void means there is no return value for the method. default(T) creates a default value for T.

var count = 3;
object boxed = count;
int restored = (int)boxed;
UO.Print(restored.ToString());

Official documentation: All built-in types - Microsoft Learn.

Clone this wiki locally