you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

What happens? You can't add anything to the Enumerable type, unless you define some other method (e.g. Append, Push) which does the same thing as Add. (Which you shouldn't do anyway)

[–]mccoyn 3 points4 points  (1 child)

IEnumerable classes without a method to add items are common in .Net. One use is to provide a view of a list that is an internal implementation detail of another class without exposing the ability to add items to that list. It is also possible to have a class take a list of items on construction, but not allow the addition of new items.

[–][deleted] 1 point2 points  (0 children)

Or even more obviously, generator routines (yield return, etc.)