The following table shows the default values of C# types:
| Type | Default value |
|---|---|
| Any reference type | null |
| Any built-in integral numeric type | 0 (zero) |
| Any built-in floating-point numeric type | 0 (zero) |
| bool | false |
| char | '\0' (U+0000) |
| enum | The value produced by the expression (E)0, where E is the enum identifier. |
| struct | The value produced by setting all value-type fields to their default values and all reference-type fields to null. |
| Any nullable value type | An instance for which the System.Nullable.HasValue property is false and the System.Nullable.Value property is undefined. That default value is also known as the null value of a nullable value type. |
ms.custom: "updateeachrelease"
The C# language reference documents the most recently released version of the C# language. It also contains initial documentation for features in public previews for the upcoming language release.
The documentation identifies any feature first introduced in the last three versions of the language or in current public previews.
Default value expressions
Use the default operator to produce the default value of a type, as the following example shows:
int a = default(int);You can use the default literal to initialize a variable with the default value of its type:
int a = default;Parameterless constructor of a value type
For a value type, the implicit parameterless constructor also produces the default value of the type, as the following example shows:
var n = new System.Numerics.Complex();
Console.WriteLine(n); // output: (0, 0)At runtime, if the System.Type instance represents a value type, you can use the System.Activator.CreateInstance(System.Type) method to call the parameterless constructor and get the default value of the type.
C# language specification
For more information, see the following sections of the C# language specification: