日期:2014-05-20  浏览次数:20836 次

Hasttable里的两个值一个key 一个value 怎么取出来?
如果定义两个string   分别等于hashtable里面的两个值?
    在线等。。谢谢。。

------解决方案--------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Hashtable ht = new Hashtable();
ht.Add( "Monday ", "星期一 ");
ht.Add( "Tuesday ", "星期二 ");
ht.Add( "Wednesday ", "星期三 ");
ht.Add( "Thursday ", "星期四 ");
ht.Add( "Friday ", "星期五 ");
ht.Add( "Saturday ", "星期六 ");
ht.Add( "Sunday ", "星期日 ");

foreach (DictionaryEntry de in ht)
{
string key = (string)de.Key;
string value = (string)de.Value;
Console.WriteLine( "Key:{0} Value:{1} ", key, value);
}
Console.Read();
}
}
}