Possible Duplicate:
why can't we define a variable inside a while loop?
I would like to simplify the following code:
string line;
while ((line = sr.ReadLine()) != null)
into:
while ((string line = sr.ReadLine()) != null)
but failed.
However, we surely can do this in for:
for (int i=0, int n=50;i<n;i++)
You can still use
for: