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 閱讀(2125) 評論(1)  編輯  收藏 所屬分類: C#

          Feedback

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

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


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


          網站導航:
           
          主站蜘蛛池模板: 昆山市| 焉耆| 桦甸市| 洪泽县| 长宁县| 全椒县| 剑川县| 康保县| 茌平县| 柳江县| 治多县| 石泉县| 栾城县| 麻阳| 杨浦区| 勃利县| 象山县| 平遥县| 清水河县| 郯城县| 青阳县| 包头市| 舟曲县| 隆昌县| 七台河市| 承德县| 炉霍县| 上犹县| 泊头市| 南漳县| 冀州市| 万年县| 霍城县| 郧西县| 岳普湖县| 蒙阴县| 老河口市| 历史| 磐石市| 青阳县| 虹口区|