using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
namespace HashTable
{
    class HashTableDemo 
    {
 
        public string Get() 
        {
            Hashtable hashTable = new Hashtable();
            hashTable.Add(1, "wuyi");
            hashTable.Add(2, "sky");
            System.Windows.Forms.MessageBox.Show((string)hashTable[1]);
 
            foreach (DictionaryEntry de in hashTable) 
            {
                System.Windows.Forms.MessageBox.Show(de.Key.ToString());
                System.Windows.Forms.MessageBox.Show(de.Value.ToString());
            }
 
            System.Collections.IDictionaryEnumerator enumerator = hashTable.GetEnumerator();
            while (enumerator.MoveNext()) 
            {
                 System.Windows.Forms.MessageBox.Show(enumerator.Key.ToString());
                System.Windows.Forms.MessageBox.Show( enumerator.Value.ToString());
            }
 
            return (string)hashTable[1];
        }
    }
}

相关文章:

  • 2022-12-23
  • 2021-08-06
  • 2021-11-30
  • 2022-02-07
  • 2021-09-11
猜你喜欢
  • 2021-10-15
  • 2021-07-09
  • 2021-07-09
相关资源
相似解决方案