以下演示的枚举类型让我惊讶,显示出来的居然是字符串形式!
using System;

public enum color
{
 Red, Blue, Green
}

public class m
{
 static void Main()
 {
  Console.WriteLine("color=" + color.Red);
 }
}
执行结果:color=Red
原先我还以为会显示:color=0 之类的。后来找资料才知道,要想让它显示出0,还要这样写:color.Red.ToString("D")

相关文章:

  • 2021-11-13
  • 2021-10-12
  • 2021-12-23
  • 2021-11-12
  • 2021-08-28
  • 2021-10-27
  • 2021-12-22
猜你喜欢
  • 2021-10-23
  • 2021-09-07
  • 2022-01-10
  • 2021-05-18
  • 2021-08-05
  • 2021-04-26
  • 2022-12-23
相关资源
相似解决方案