T
Tony Johansson
Hi!
This first example works
static void Main(string[] args)
{
int j;
int i;
for (i = 0, j = 1; i <= j; i++,j -=2 )
Console.WriteLine("i= {0} j={1}", i, j);
}
but this second example get compile error saying se below
static void Main(string[] args)
{
int j;
//int i;
for (int i = 0, j = 1; i <= j; i++,j -=2 )
Console.WriteLine("i= {0} j={1}", i, j);
}
Error 1 A local variable named 'j' cannot be declared in this scope because
it would give a different meaning to 'j', which is already used in a 'parent
or current' scope to denote something else
F:\C#\ConsoleApplication1\Report.cs 18 26 ConsoleApplication1
I don't understand why my second example doesn't work when the first example
worked ?
//Tony
This first example works
static void Main(string[] args)
{
int j;
int i;
for (i = 0, j = 1; i <= j; i++,j -=2 )
Console.WriteLine("i= {0} j={1}", i, j);
}
but this second example get compile error saying se below
static void Main(string[] args)
{
int j;
//int i;
for (int i = 0, j = 1; i <= j; i++,j -=2 )
Console.WriteLine("i= {0} j={1}", i, j);
}
Error 1 A local variable named 'j' cannot be declared in this scope because
it would give a different meaning to 'j', which is already used in a 'parent
or current' scope to denote something else
F:\C#\ConsoleApplication1\Report.cs 18 26 ConsoleApplication1
I don't understand why my second example doesn't work when the first example
worked ?
//Tony