What is the use of `default` keyword in C#?

前端 未结 6 654
盖世英雄少女心
盖世英雄少女心 2020-11-30 01:38
  1. What is the use of default keyword in C#?
  2. Is it introduced in C# 3.0 ?
6条回答
  •  情歌与酒
    2020-11-30 02:19

    The default keyword has different semantics depending on its usage context.

    The first usage is in the context of a switch statement, available since C# 1.0:
    http://msdn.microsoft.com/en-us/library/06tc147t(VS.80).aspx

    The second usage is in the context of generics, when initializing a generic type instance, available since C# 2.0:
    http://msdn.microsoft.com/en-us/library/xwth0h0d(VS.80).aspx

提交回复
热议问题