I read "C # Start" to update my memory in C # (C ++ background).
I found this snippet in a book:
int i; string text; for (i = 0; i < 10; i++) { text = "Line " + Convert.ToString(i); Console.WriteLine("{0}", text); } Console.WriteLine("Last text output in loop: {0}", text);
The above snippet will not compile, because according to the book, the variable text is not initialized (initialized only initialized in the loop), and the last value assigned to it is lost when the loop exits.
I cannot understand why the value assigned to the value of L is lost only because the area in which the value of R was created was displayed - although the value of L is still in scope.
Can someone explain why the variable text loses the value assigned in the loop ?.
c # compiler-errors
morpheous
source share