I am newbie in asp.net and I want to insert data from my dynamic form in the database. To identify fields I am also saving the labels of the fields in the database.
For this purpose I want to use a multi dimensional array. The problem is that I want to declare the key of the array when I assig the value, like we do below in php:
myarray['key_label'] = 'key_value';
I am not sure how can I do this in C#.net. I searched and found dictionary for this purpose, so I used the below code, but in this case I can view key or value any one at once:
var dictionary = new Dictionary<string, object>();
dictionary.Add("username", rpu);
dictionary.Add("sec_username", rcu);
dictionary.Add("co_type", ct);
Kindly guide me for below
how can I assign the value of an array like I mentioned above?
I found a way to display both key and values together, mentioned below but is it possible that i can make dictionary multi dimensional like we do for arrays?
Dictionary<int, string> plants = new Dictionary<int, string>() { {1,"Speckled Alder"}, {2,"Apple of Sodom"}, {3,"Hairy Bittercress"}, {4,"Pennsylvania Blackberry"}, {5,"Apple of Sodom"}, {6,"Water Birch"}, {7,"Meadow Cabbage"}, {8,"Water Birch"} }; Response.Write("<b>dictionary elements........</b><br />"); //loop dictionary all elements foreach (KeyValuePair<int, string> pair in plants) { Response.Write(pair.Key + "....." + pair.Value + "<br />"); } //find dictionary duplicate values. var duplicateValues = plants.GroupBy(x => x.Value).Where(x => x.Count() > 1); Response.Write("<br /><b>dictionary duplicate values..........</b><br />"); //loop dictionary duplicate values only foreach (var item in duplicateValues) { Response.Write(item.Key + "<br />"); }}