How to use Dictionary (IDictionary) in ASP .NET and in C# Example/Sample Code

How to use Dictionary (IDictionary) in ASP .NET and in C# Example/Sample Code

ASP.NET and C# sample Code: 

IDictionary<string, string> object = new Dictionary<string, string>();
if(!object.ContainsKey(<Key>))
object.Add(<key>, <Value>);

// Get the value from Dictionary
String strValue = object[<Key>];

// Get the values from Dictionary using KeyValuePair
foreach (KeyValuePair<string, string> kvPair in values)
{
String key = kvPair.Key;
String Value = kvPair.Value;
---------
}

1 comment:

  1. To ensure application performance one must think over its architecture, You should pick necessary components.
    netperformance

    ReplyDelete