I have the following classes:
class Word { }
class Sentence: List<Word> { }
class TextSection: List<Sentence> { }
class TextBase: List<TextSection> { }
And I want to be able to work with TextBase
as if it was a collection of Word
s, i.e. iterate over it with foreach
, use Select
and Aggregate
methods.
There are some important additional fields and methods in all of those classes so replacing them with TextBase: List<Word>
is not an option.
What is the best way to do that?
UPD: Implementing IEnumerable<Word>
will solve part of my problem, but now when I call TextBase.Where()
it will return IEnumerable<Word>
It will ruin my breakdown of base into sections, sections into sentences etc. Can I avoid that?