C#: System.Collections.Generic.Dictionary

Namespace:

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>();

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");


Loop Through ArrayList of Dictionary Type:

foreach (Dictionary<string, string> dic in aList)
{
Response.Write("id: " + dic["id"] + " username: " + dic["username"] + "<br>");
}

Comments

Popular posts from this blog

SQL: GROUP BY And HAVING

Installing AdventureWorks Sample Databases from Microsoft

ASP.NET MVC 5 From Scratch : Add JQuery UI Library Using NuGet