在将 id 传递给方法的情况下,执行以下操作的最佳方法是什么。案例陈述可以还是像哈希表这样的某种集合更好?
private string GetCurrencySymbol(string code)
{
switch (code)
{
case "USD":
case "AUD":
case "CAD":
case "NAD":
case "NZD":
case "SGD":
case "HKD":
return "$";
case "GBP":
return "£";
case "NOK":
case "DKK":
case "SEK":
return "kr";
case "ZAR":
return "R";
case "JPY":
return "¥";
case "CHF":
return "CHF";
case "EUR":
return "€";
case "GHS":
return "¢";
case "BWP":
return "P";
case "INR":
return "₹";
case "KES":
return "KSh";
case "LSL":
return "L";
case "MUR":
return "Rs";
case "NGN":
return "₦";
case "MWK":
return "MK";
case "MZM":
return "MT";
case "PKR":
return "Rs";
case "PLN":
return "zł";
case "SZL":
return "L";
case "TZS":
return "Sh";
case "UGX":
return "Sh";
case "ZMK":
return "ZK";
default:
return "";
}
}
这个好像有点味道?它并不经常访问,但似乎有点冗长。