hashTable.Add("person", new person() { Name="hashTable",sex="sex",Age=12}); foreach (DictionaryEntry item in hashTable) { person p = (person)hashTable.Values; strHashTable += p.Name + "/" + p.Age + "/" + p.sex; }
这样会报错。那如何写呢?
foreach (DictionaryEntry item in hashTable) { person p = (person)item.Value; strHashTable += p.Name + "/" + p.Age + "/" + p.sex; }
非常正确那!谢谢指点