如何获取密钥和值数组对象
你可以这样做:
foreach(KeyValuePair<string, string> kv in st[u])
{
string key = kv.Key;
string val = kv.Value;
//Business logic here
}
我很确定这是我的错。 – 2017-10-11 05:31:57
您可以用KeyValuePair
尝试获得键和数组中的值。
foreach(KeyValuePair<string, string> kvp in m)
{
Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
}
你缺少一个空间。 – 2017-10-11 05:29:51
@someone但在OP图像中有数组列表。不可hastable? –
是的,这就是我解决我的评论的原因。 – 2017-10-11 05:31:37
Hashtable hashtable = new Hashtable();
hashtable[1] = "One";
hashtable[2] = "Two";
hashtable[13] = "Thirteen";
foreach (DictionaryEntry entry in hashtable)
{
Console.WriteLine("{0}, {1}", entry.Key, entry.Value);
}
You can use hashtable like this
为什么使用ArrayLists? – 2017-10-11 05:23:15
支持net 2.0 –
为什么你仍然使用.net 2.0?列表似乎在那里。 –
2017-10-11 05:24:32