Try:
class StringToDictionary : Dictionary<string, StringToDictionary> { }
Then you can write:
var stuff = new StringToDictionary
{
{ "Fruit", new StringToDictionary
{
{ "Apple", null },
{ "Banana", null },
{ "Lemon", new StringToDictionary { { "Sharp", null } } }
}
},
};
General principle for recursion: find some way to give a name to the recursive pattern, so it can refer to itself by name.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…