Compiler is correct, you are wrong. The error is in the second fragment of code:
foreach (string dataLine in userData) …
Here,
userData
is not declared. If, by some weird reason. you think that having
Array userData
mentioned above makes any difference, you are wrong: this is the declaration of the stack (local) variable, which only exist in the current stack frame, where it was declared.
Moreover, calculating the
userData
object you show
makes no sense at all: when you go out of context (enclosing '
{… }
' pair), this object becomes
unreachable and eventually gets destroyed by the Garbage Collection. To understand it, please see:
http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29[
^].
—SA