0
Dictionary fruit<string,string> = new Dictionary<string,string>();
fruit.Add("name","orange");
fruit.Add("vitamin","C");

I want call value with key. But, if i am write fruit.Key, c# is giving "name" what is problem?

stuartd
  • 70,509
  • 14
  • 132
  • 163

2 Answers2

0

Both will work:

string name = fruit["name"];

or:

string vit = fruit.Single(c => c.Key == "vitamin").Value;
mr.coffee
  • 962
  • 8
  • 22
0

Problem is here (from my worktable) :

WhatisMethodForGetValue()  {
//????????????????????????????
}



  var tas = new Dictionary<string, string>();

      string sayi;
            string renk;
            bool okey = false;

                    tas["sayi"] = seriler[j];
                    tas["renk"] = renkler[i];
                    tas["okey"] = okey.ToString();



  foreach (KeyValuePair<string, string> mytas in (dynamic)TAS[v])
                {


Button Tas = new Button();
                    Tas.BackColor = Color.White;
Tas.Text = WhatisMethodForGetValue(mytas["sayi"]);
            }