54powerman

          開源~節流

          C#集合類使用范例

          //Dictionary
          System.Collections.DictionaryEntry dic=new System.Collections.DictionaryEntry("key1","value1");

          //ArrayList
          System.Collections.ArrayList list=new System.Collections.ArrayList();
          list.Add(1);
          list.Add(2);
          for(int i=0;i<list.Count;i++)
          {
          ?System.Console.WriteLine(list[i]);
          }

          //HashTable
          System.Collections.Hashtable table=new System.Collections.Hashtable();
          table.Add("table1",1);
          table.Add("table2",2);
          System.Collections.IDictionaryEnumerator d=table.GetEnumerator();
          while(d.MoveNext())
          {
          ?System.Console.WriteLine(d.Entry.Key);
          }

          //Queue
          System.Collections.Queue queue=new System.Collections.Queue();
          queue.Enqueue(1);
          queue.Enqueue(2);

          System.Console.WriteLine(queue.Peek());
          while(queue.Count>0)
          {
          ?System.Console.WriteLine(queue.Dequeue());
          }

          //SortedList
          System.Collections.SortedList list=new System.Collections.SortedList();
          list.Add("key2",2);
          list.Add("key1",1);
          for(int i=0;i<list.Count;i++)
          {
          ?System.Console.WriteLine(list.GetKey(i));
          }

          //Stack
          System.Collections.Stack stack=new System.Collections.Stack();
          stack.Push(1);
          stack.Push(2);

          System.Console.WriteLine(stack.Peek());
          while(stack.Count>0)
          {
          ?System.Console.WriteLine(stack.Pop());
          }

          posted on 2006-10-18 15:48 54powerman 閱讀(2126) 評論(1)  編輯  收藏 所屬分類: C#

          Feedback

          # re: C#集合類使用范例 2009-04-14 15:55 w

          ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 德清县| 东方市| 枣强县| 衡东县| 博白县| 东阳市| 遂宁市| 视频| 蓝田县| 信宜市| 芒康县| 永春县| 新晃| 阜阳市| 信阳市| 南和县| 永康市| 通河县| 平塘县| 富民县| 贵阳市| 康马县| 博白县| 光山县| 永嘉县| 吉林市| 敦化市| 清流县| 宿松县| 喀喇| 枣庄市| 深泽县| 蕉岭县| 定襄县| 贡嘎县| 镇江市| 平远县| 金昌市| 武川县| 山东省| 兴安县|