And they say that recursion is divine!
Let's start with the biggest nesting, with the words that make up the sentence.
var sentence = new List<string>(); sentence.Add("Hello"); sentence.Add("world");
Words are combined into sentences that make up the text:
var text = new List<List<string>>(); var sentence = new List<string>(); sentence.Add("Hello"); sentence.Add("world"); text.Add(sentence);
The last code can be rewritten as follows:
var text = new List<List<string>>(); text.Add(new List<string>()); text[text.Count - 1].Add("Hello"); text[text.Count - 1].Add("world");
Here we first add an empty sentence to the text, and then add words to the last ( text[text.Count - 1] ) text sentence.
If we had another level of nesting, for example, a card file, which consists of texts, it would look like this:
var directory = new List<List<List<string>>>(); var text = new List<List<string>>(); var sentence = new List<string>(); sentence.Add("Hello"); sentence.Add("world"); text.Add(sentence); directory.Add(text);