Using C# default keyword

4/1/2014

C# .NET's default keyword can be used as if you don't know what's Type is coming, like type T. It's basically return the default value of the type. For exmple: default(int) is 0.

I did a research of what's result will return by various kind of type.

  • int
  • bool
  • string
  • DateTime
  • char
  • sbyte
  • short
  • long
  • byte
  • ushort
  • uint
  • ulong
  • float
  • double
  • object
  • Enum
  • int?
  • Nullable

1. what's I tried to test result. 

2. what's the result 

3. As a result: string, object, Nullable, List, class'll return null result. Numbers will return 0.

click following button if you want to download this sample application.