Code for adding to IEnumerable

Sudha picture Sudha · Apr 2, 2013 · Viewed 47.1k times · Source

I have an enumerator like this

IEnumerable<System.Windows.Documents.FixedPage> page;

How can I add a page (eg: D:\newfile.txt) to it? I have tried Add, Append, Concat etc But nothing worked for me.

Answer

Mark Broadhurst picture Mark Broadhurst · Apr 2, 2013

IEnumerable<T> does not contain a way to modify the collection.

You will need to implement either ICollection<T> or IList<T> as these contain an Add and Remove functions.