Skip to content

Latest commit

 

History

History
62 lines (56 loc) · 2.78 KB

File metadata and controls

62 lines (56 loc) · 2.78 KB
title Default values table (C# Reference)
descripton Learn what are the default values of value types returned by the default constructors.
ms.date 07/20/2015
ms.prod .net
ms.technology
devlang-csharp
ms.topic article
helpviewer_keywords
constructors [C#], return values
keywords [C#], new
default constructor [C#]
defaults [C#]
value types [C#], initializing
variables [C#], value types
constructors [C#], default constructor
types [C#], default constructor return values
ms.assetid 4af2c1df-9e3a-48c1-83ac-b192986fc5bc
caps.latest.revision 12
author BillWagner
ms.author wiwagn

Default values table (C# Reference)

The following table shows the default values of value types returned by the default constructors. Default constructors are invoked by using the new operator, as follows:

int myInt = new int();

The preceding statement has the same effect as the following statement:

int myInt = 0;

Remember that using uninitialized variables in C# is not allowed.

Value type Default value
bool false
byte 0
char '\0'
decimal 0M
double 0.0D
enum The value produced by the expression (E)0, where E is the enum identifier.
float 0.0F
int 0
long 0L
sbyte 0
short 0
struct The value produced by setting all value-type fields to their default values and all reference-type fields to null.
uint 0
ulong 0
ushort 0

See also

C# Reference
C# Programming Guide
Value Types Table
Value Types
Built-In Types Table
Reference Tables for Types