public static void Main()
{
int n;
//n++; Of course it would cause 'Use of unassigned local variable error' compiler error.
int.TryParse("not an int", out n); //not assignig here
n++; //now legal. Why?
System.Console.WriteLine(n); //1
}
I can't understand why this code behave like that. In the beginning it doesn't allow to use unassigned variable but after TryParse it does, though TryParse don't assign anything to variable. At some point variable is assigned to default value 0 (I suppose from start) but what is the logic and explanation of such behavior?