我在C#Brain teasers http://www.yoda.arachsys.com/csharp/teasers.html上浏览了Jon skeet网站.为什么项目"Baz"在输出中显示,即使我为枚举中的所有项目声明了默认值
---例如:1
class Test
{
enum Foo { Bar, Baz,bread, jam };
const int One = 1;
const int Une = 1;
static void Main()
{
Foo f = 0;
Console.WriteLine(f);
Console.ReadLine();
}
}
// output :Bar
Run Code Online (Sandbox Code Playgroud)
--eg2
class Test
{
enum Foo { Bar, Baz,bread=0, jam };
const int One = 1;
const int Une = 1;
static void Main()
{
Foo f = 0;
Console.WriteLine(f);
Console.ReadLine();
}
}
//output : Bar
Run Code Online (Sandbox Code Playgroud)
--eg3
class Test …Run Code Online (Sandbox Code Playgroud)