0

I need to get data from dictionary that is in format like this :

private Dictionary<string, Dictionary<string, string>> MyDictionary = new    Dictionary<string, Dictionary<string, string>>()
{
    {"HEIGHT", new Dictionary<string,string>(){{"table", "TR_HEIGHT"}, {"prefix", "HEI"}}},
    {"WEIGHT", new Dictionary<string,string>(){{"table", "TR_WEIGHT"}, {"prefix", "WIL"}}},
    {"LENGTH", new Dictionary<string,string>(){{"table", "TR_LENGTH"}, {"prefix", "LEN"}}},
};

It is posible to if I insert "HEIGHT" i get back prefix is "HEI" and table is "TR_HEIGHT"?

Thank's

5
  • 1
    If the keys are known to always exist: var prefix = MyDictionary["HEIGHT"]["prefix"]; Commented May 7, 2014 at 10:58
  • That code does not compile Commented May 7, 2014 at 10:59
  • It is posible to if I insert "HEIGHT" i get back prefix is "HEI" and table is "TR_HEIGHT"? Please clearify. Commented May 7, 2014 at 11:00
  • 1
    @Alberto The code only didn't compile because of a missed quote (easy to do if the code was manually typed into the editor), you could have fixed it. Commented May 7, 2014 at 11:02
  • Its work great, tank you @Adam Houldsworth for fast answer. Commented May 7, 2014 at 11:06

1 Answer 1

2

It is posible to if I insert "HEIGHT" i get back prefix is "HEI" and table is "TR_HEIGHT"?

Yes

Dictionary<string, string> heightAttr = MyDictionary["HEIGHT"];
string table  = heightAttr["table"];    //  TR_HEIGHT
string prefix = heightAttr["prefix"];   //  HEI
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.