我正在将一个Java项目转换成C#。我已经尝试搜索这个问题,但是所有相关的都是关于枚举类型的问题。有一个Hashtable htPlaylist,并且循环使用Enumeration去遍历键。如果我想使用Dictionary而不是Hashtable来进行转换,该如何修改代码?
// My C# Dictionary, formerly a Java Hashtable.
Dictionary<int, SongInfo> htPlaylist = MySongs.getSongs();
// Original Java code trying to convert to C# using a Dictionary.
for(Enumeration<Integer> e = htPlaylist.keys(); e.hasMoreElements();
{
// What would nextElement() be in a Dictonary?
SongInfo popularSongs = htPlaylist.get(e.nextElement());
}