所以我最近一直在研究 C#,所有的通用集合都让我有点困惑。假设我想表示一种数据结构,其中树的头部是一个键值对,然后在其下方有一个可选的键值对列表(但不超过这些级别)。这会合适吗?
public class TokenTree
{
public TokenTree()
{
/* I must admit to not fully understanding this,
* I got it from msdn. As far as I can tell, IDictionary is an
* interface, and Dictionary is the default implementation of
* that interface, right?
*/
SubPairs = new Dictionary<string, string>();
}
public string Key;
public string Value;
public IDictionary<string, string> SubPairs;
}
这只是传递数据的简单分流。