是枚舉類型更快/更有效比字符串類型當用作字典鍵?哪一個更快/更高效:Dictionary <字符串,對象>或字典<enum,object>?
IDictionary<string,object> or IDictionary<enum,object>
事實上,哪種數據類型最適合作爲字典鍵,爲什麼?
考慮以下幾點:注:僅5個屬性爲簡單起見
struct MyKeys
{
public string Incomplete = "IN";
public string Submitted = "SU";
public string Processing="PR";
public string Completed = "CO";
public string Closed = "CL";
}
和
enum MyKeys
{
Incomplete,
Submitted,
Processing,
Completed,
Closed
}
如果用作字典中的按鍵,上面會更好!
C#是否具有與Java的EnumMap相同的功能? – 2009-05-04 13:56:43