现在我有
public enum EnumSize { Miniscule, Tiny, Small, Medium, Large, Huge, Giant }
我想要返回字符串值,所以我做了一个 switch 语句来返回字符串值
public string getSize()
{
string temp = "";
switch (pSize)
{
case EnumSize.Miniscule: temp = "Miniscule"; break;
case EnumSize.Tiny: temp = "Tiny"; break;
case EnumSize.Small: temp = "Small"; break;
case EnumSize.Medium: temp = "Medium"; break;
case EnumSize.Large: temp = "Large"; break;
case EnumSize.Huge: temp = "Huge"; break;
case EnumSize.Giant: temp = "Giant"; break;
}
return temp;
}
这样做有什么缺点?有没有更好的方法?谢谢!