public static Dictionary<int, string> dic = new Dictionary<int, string>() {
{1,"anystring1"},
{2,"anystring2"}};
I need to use this
string str= dic[1]; // it is possible
int a=dic["anystring1"]; // My dream is it
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is not what a dictionary is meant to do. Can you think of a definition and instantly find the matching word in your favorite dictionary in
O(1)time? If you want a class with that type of functionality (a bidirectional dictionary) you will have to build it yourself (or Google for one of many implementations on the Internet).