t
is an
IEnumerable<T>
, not a
List<T>
And
folder
can only contain Lists which are a "superset" of IEnumerable.
You can do it the other way around:
IEnumerable<string> t;
List<string> folder = new List<string>();
t = folder;
Because every List is IEnumerable - but you can't do it the other way.
Think about it: what would happen if you could? When you tried to use the List, the List specific features (indexing, adding and removing items, etc.) would not be there, so teh code would fail.
You can do it by using a Linq method to convert the IEnumerable to a List:
IEnumerable<string> t = ...;
List<string> folder = t.ToList();
But that creates a new object (a List) which contains the same items as the original IEnumerable, but which is not "attached" to it, so changes to one will not affect the other.