public static Dictionary<int, string> dic = new Dictionary<int, string>() {
{1,"anystring1"},
{2,"anystring2"}};
Run Code Online (Sandbox Code Playgroud)
我需要用这个
string str= dic[1]; // it is possible
int a=dic["anystring1"]; // My dream is it
Run Code Online (Sandbox Code Playgroud)
我在这一点上有点晚了,但LINQ是你的朋友:
MyDict.FirstOrDefault(pair => pair.Value == "the value you want").Key;
Run Code Online (Sandbox Code Playgroud)
让你做你想做的.
| 归档时间: |
|
| 查看次数: |
17494 次 |
| 最近记录: |