C# 获取Hashtable中的Key和Value

//定义一个Hashtable
public static Hashtable hstFileInfo = new Hashtable();

//给Hashtable添加数据
if (!hstFileInfo.Contains(ID))
{
hstFileInfo.Add(ID, Name);
}

//循环Hashtable,获取Key和Value
foreach (DictionaryEntry fl in hstFileInfo) //获取文件
{
string Key = fl.Key.ToString(); //Key
string Value = (string)fl.Value.ToString(); //Value
}

posted @ 2020-07-28 17:31  SelenaZhou  阅读(4104)  评论(0编辑  收藏  举报