namespace ConsoleApp1
{
class Program
{
static unsafe void Main(string[] args)
{
int x = default(int);
// 0
Console.WriteLine(x);
// 简化
int y = default;
// 0
Console.WriteLine(y);
double d = default(double);
// 0
Console.WriteLine(d);
Form form = default(Form);
// 空
Console.WriteLine(form);
// True
Console.WriteLine(form == null);
Level level = default(Level);
// Low 枚举类型的第一个
Console.WriteLine(level);
Level2 level2 = default(Level2);
// Mid
Console.WriteLine(level2);
}
}
/// 枚举类型
enum Level
{
Low,
Mid,
High
}
enum Level2
{
Low = 1,
Mid = 0,
High = 2
}
}
c# default
最新推荐文章于 2024-06-21 09:55:53 发布