Supposing I have a string which I want to convert to an integer, I would do
int i;
int.TryParse(someString, out i);
Now I would like to do the same in a Linq query:
int i;
var numbers =
from s in someStrings
where int.TryParse(s, out i)
select i;
But this refuses to compile with the error
CS0165 Use of unassigned local variable 'i'
It compiles and works as intended when I initialize i to an arbitraty value. But why do I have to?