sbornstein2
asked on
Get Key Value from Generic Dictionary Question
Hello all,
I have in MVC this "RouteValueDictionary" and in this it has 3 key value pairs such as this:
Keys:
[0] Data
[1] Total
[2] Errors
Then under Values I have the following if I click on Values:
[0] Count = 1
[1] 1
[2] Count = 1
If I expand the [2] I see:
[0] = {[key, System.Collections.Generic .Dictionar y`2[System .String,Sy stem.Objec t]]}
Then under that I see:
Key: "key"
Value: Count = 1
Then I see when I expand the value:
[0] = {[errors, System.String[]]}
Then again I expand the [0] I see:
Key = "errors"
Value = {string[1]}
Then Finally I see what I am trying to get at under value expanded:
[0] = "Error Message"
How do I get to this key value?
I have in MVC this "RouteValueDictionary" and in this it has 3 key value pairs such as this:
Keys:
[0] Data
[1] Total
[2] Errors
Then under Values I have the following if I click on Values:
[0] Count = 1
[1] 1
[2] Count = 1
If I expand the [2] I see:
[0] = {[key, System.Collections.Generic
Then under that I see:
Key: "key"
Value: Count = 1
Then I see when I expand the value:
[0] = {[errors, System.String[]]}
Then again I expand the [0] I see:
Key = "errors"
Value = {string[1]}
Then Finally I see what I am trying to get at under value expanded:
[0] = "Error Message"
How do I get to this key value?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can try this:
Dictionary<String, Object> test = new Dictionary<String, Object>();
Object value = null;
if (test.TryGetValue("myKey", out value))
Console.WriteLine("myKey exists.");
dic["A"] = "Ahmed";
dic["B"] = "Boys";
foreach (string mk in dic.Keys)
{
if(dic[mk]=="Ahmed")
Console.WriteLine("key contain \"Ahmed\" is "+mk);
}