System.Collections.Generic
Declaration:
Dictionary<string, string> account = new Dictionary<string, string>();
Adding Items:
account.Add("id","1");
account.Add("username", "jackd");
Use in ArrayList: Namespace:
System.Collections
Add Dictionary to ArrayList:
Dictionary<string, string> account = new Dictionary<string, string>();Loop Through ArrayList of Dictionary Type:
ArrayList aList = new ArrayList();
account.Add("id","1");
account.Add("username", "jackd");
aList.Add(account);
account = new Dictionary<string, string>();
account.Add("id","2");
account.Add("username", "janed");
aList.Add(account);
account = new Dictionary<string, string>();
account.Add("id","3");
account.Add("username", "d");
foreach (Dictionary<string, string> dic in aList)
{
Response.Write("id: " + dic["id"] + " username: " + dic["username"] + "<br>");
}
No comments:
Post a Comment