How can I get the dictionary value by key on function
my function code is this ( and the command what I try but didn't work ):
static void XML_Array(Dictionary<string, string> Data_Array)
{
String xmlfile = Data_Array.TryGetValue("XML_File", out value);
}
my button code is this
private void button2_Click(object sender, EventArgs e)
{
Dictionary<string, string> Data_Array = new Dictionary<string, string>();
Data_Array.Add("XML_File", "Settings.xml");
XML_Array(Data_Array);
}
I want something like this:
on XML_Array
function to be
string xmlfile = Settings.xml
Why not just use key name on dictionary, C# has this:
If you look at the tip suggestion:
Here is example which I use in my source code. I am getting key and value from Dictionary from element 0 to number of elements in my Dictionary. Then I fill my string[] array which I send as a parameter after in my function which accept only params string[]
Hope this will help you and the others. This solution works with SortedDictionary also.
Kind regards,
Ozren Sirola