This question is also asked by others. I will post it for your reference.
C # code
Public class Person
{
Public String Name {set; get ;}
Public int Age {set; get ;}
Public String Url {set; get ;}
}
Protected void Page_Load (object sender, EventArgs e)
{
// Short form of Dictionary
Dictionary <int, String> dict = new Dictionary <int, string> () {1, "A" },{ 2, "BB "}};
Foreach (KeyValuePair <int, String> d in dict)
{
Response. Write ("<li>" + d. Key + "=" + d. Value );
}
// The abbreviated form of Hashtable is www.2cto.com.
Hashtable myHash = new Hashtable () {"key1", "AA" },{ "key2", "BB "}};
Foreach (DictionaryEntry d in myHash)
{
Response. Write ("<li>" + d. Key + "=" + d. Value );
}
ArrayList ar = new ArrayList () {"A", "B", "C "};
Foreach (string d in ar)
{
Response. Write ("<li>" + d );
}
// Create a common object
Person p = new Person () {Name = "net_lover", Age = 28, Url = "http://dotnet.aspx.cc "};
}
Author: Meng xianhui