Skip to content

Value Types

Value types store data directly on the stack. When you assign a value type to another variable, a copy is made.

int a = 10;
int b = a; // copy
b = 20;
Console.WriteLine($"a: {a}, b: {b}");
Terminal window
dotnet run
Terminal window
a: 10, b: 20