Basic usage examples of ES0en. NET Dictionary
- 2020-09-28 08:51:29
- OfStack
Dictionary<string, string> o_Dic = new Dictionary<string, string>();
// Add elements
o_Dic.Add("01", "aaa");
o_Dic.Add("02","bbb");
// Determine whether a key If there is a
if (!o_Dic.ContainsKey("03"))
{
o_Dic.Add("03", "ccc");
}
// To remove a
o_Dic.Remove("03");
// Take some value
string a = o_Dic["02"];
// It �
foreach (KeyValuePair<string, string> kvp in o_Dic)
{
Response.Write(kvp.Key + "," + kvp.Value);
}
// It � key
foreach (string s in o_Dic.Keys) { }
// It � value
foreach (string s in o_Dic.Values) { }