枚举的应用
GetEmu(CustomerKind.Normal);
public enum CustomerKind
{
Normal = 90,
Vip = 80,
SuperVip = 70,
InActive = 100
}
//一种是用来判断
public void GetEmu(CustomerKind c)
{
switch (c)
{
case CustomerKind.Normal:
Response.Write((int)CustomerKind.Normal);
break;
case CustomerKind.Vip:
Response.Write((int)CustomerKind.Vip);
break;
default:
Response.Write((int)CustomerKind.InActive);
break;
}
}
//另一种是用来计算
void bind()
{
if (Request.QueryString["id"] == null)
{
Response.Write(300/100 * (int)CustomerKind.Normal);
Response.Write(CustomerKind.Normal);
}
else
{
Response.Write(CustomerKind.Vip);
Response.Write(300 / 100 * (int)CustomerKind.Vip);
}
}
void bind()
{
if (Request.QueryString["id"] == null)
{
Response.Write(300/100 * (int)CustomerKind.Normal);
Response.Write(CustomerKind.Normal);
}
else
{
Response.Write(CustomerKind.Vip);
Response.Write(300 / 100 * (int)CustomerKind.Vip);
}
}