C# 代码

  public class Person
  {
    public String Name { setget; }
    public int Age { setget; }
    public String Url { setget; }
  }


  protected void Page_Load(object sender, EventArgs e)
  {
    //Dictionary 的简写形式
    Dictionary<int, String> dict = new Dictionary<intstring>() { { 1"A" }, { 2"BB" } };
    foreach (KeyValuePair<int, String> d in dict)
    {
      Response.Write("<li>" + d.Key + " = " + d.Value);
    }

    //Hashtable 的简写形式
    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);
    }

    //创建普通对象
    Person p = new Person() { Name = "net_lover", Age = 28, Url = "http://dotnet.aspx.cc" };
  }
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2021-11-29
  • 2022-03-05
  • 2022-12-23
  • 2021-06-15
  • 2021-07-16
相关资源
相似解决方案