On Jun 2, 1:31 pm, Hakan Fatih YILDIRIM <hfysilis...@gmail.comwrote:
Good point Marc.. Thanks
Hi,
from MSDN:
"This error occurs when an assignment to variable occurs in a read-
only context. Read-only contexts include foreach iteration variables,
using variables, and fixed variables. To resolve this error, avoid
assignments to a statement variable in using blocks, foreach
statements, and fixed statements."
The foreach keyword just enumerates IEnumerable instances (getting an
IEnumerator instances by calling the GetEnumerator() method).
IEnumerator is read-only, therefore values can't be changed using
IEnumerator =can't be changed using the foreach context.
Hope this helps.
Moty