//客户端
class Program
{
static void Main(string[] args)
{
//学习格式字符串的用法
string[] str = new string[] { "a", "b" };
string[] str1 = new string[2] { "c","d"};
string[] str2 ={ "e","g"};
//调用testenum枚举
//要使用枚举,须先定义一个枚举类型的变量
testenum enum1;
enum1 = testenum.first;//为枚举类型的变量进行初始化值,是通过枚举类型的元素进提供
Console.WriteLine("枚举类型testenum变量的值是:{0}", enum1);
//if (enum1==testenum.first) //一般使用枚举类型变量==枚举类型.枚举类型的元素
if ((int)enum1==1) //枚举变量显式转化为枚举元素对应的值
{
Console.WriteLine("haha");
}
Console.ReadKey();
}
//定义枚举类型
public enum testenum:int //枚举默认类型是int
{
first=1,
second=2,
third=3
}
}
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-734719/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-734719/