J
John Smith
In the following (pseudo)code, why is it that C# returns an
"unassigned local variable" error for nVar? It seems I have to
declare the variable outside foo() for the error to dissapear.
void foo()
{
int nVar = 0;
SqlDataReader rdr = objCmd.ExecuteReader();
while (rdr.Read())
{
nVar = rdr[0];
}
int nVar2 = nVar;
}
Thank you.
"unassigned local variable" error for nVar? It seems I have to
declare the variable outside foo() for the error to dissapear.
void foo()
{
int nVar = 0;
SqlDataReader rdr = objCmd.ExecuteReader();
while (rdr.Read())
{
nVar = rdr[0];
}
int nVar2 = nVar;
}
Thank you.