Why is foreach loop a read only? I mean you can fetch the data but can\'t increase++ or decrease--. Any reason behind it? Yes I am a beginner :)
Exmaple:
Because the current element is returned by value(i.e. copied). And modifying the copy is useless. If it is a reference type you can modify the content of that object, but can't replace the reference.
Perhaps you should read the documentation of IEnumerable and IEnumerator. That should make it clearer. The most important bit is that IEnumerable has a property Current of type T. And this property has only a getter, but no setter.
But what would happen if it had a setter?
select(x=>f(x)) the values are results of a function and have no permanent storage associated.yield return syntax it doesn't make sense either