public static Dictionary<int, string> dic = new Dictionary<int, string>() {
{1,"anystring1"},
{2,"anystring2"}};
我需要用这个
string str= dic[1]; // it is possible
int a=dic["anystring1"]; // My dream is it
最佳答案
使用另一个 Dictionary<>
并以键/值的相反顺序使用它。
关于c# - 如何在c#中以两种方式使用字典,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4191462/