N
NotYetaNurd
for(int i=0;i<6;i++)
{
//
}
wont i go out of scope after the for loop ...?
{
//
}
wont i go out of scope after the for loop ...?
Champika Nirosh said:that is since
for (int i=0; i<6; i++) === int i; for(i=0; i<6; i+)
NotYetaNurd said:when i tried this
for(int i=0;i<6;i++)
{
for(int j=0;j<someConst;j++)
{
}
}
int i=1;
foreach(.......)
{
asdf=--i;
}
I am getting the following error
"A local variable named 'i' cannot be declared in this scope because it
would give a different meaning to 'i', which is already used in a 'child'
scope to denote something else
Champika Nirosh said:Yes that won't work and let me explain it this way
Even if the scope of an element is limited to the block, its lifetime is
still that of the entire procedure.
NotYetaNurd said:if it has the scope for the entire block the following should compile rite
{
for (int i=0; i < 6; i++)
{
...
}
i=1;
}
but am getting
" The name 'i' does not exist in the class or namespace......."
Champika Nirosh said:What proof you have to say that the the variable (which define in a block)
lifetime is not equal to that of the entire procedure.
your example is not capable of talking about the life time and I am not
talking about the SCOPE.
Champika Nirosh said:What proof you have to say that the the variable (which define in a block)
lifetime is not equal to that of the entire procedure.
your example is not capable of talking about the life time and I am not
talking about the SCOPE.
Nirosh.
Champika Nirosh said:If i defined in the procudure has the scope for its entire procedure I
should be able to do some thing like
i = 0;
int i;
but this is not possible why?
Champika Nirosh said:
Champika Nirosh said:What proof you have to say that the the variable (which define in a block)
lifetime is not equal to that of the entire procedure.
your example is not capable of talking about the life time and I am not
talking about the SCOPE.