So I am pretty new at C# and most of my programming experience has actually come from years of PHP work. As far i can tell I've declared my variables correctly inside of my class. Yet, inside of my Main method I am getting compiler error CS0120 that the 'isnegative' variable does not exist in the current context.
Are variables not class wide?
namespace ConsoleApplication1
{
class Program
{
public int isnegative;
static void Main()
{
isnegative = 0;
for (int i; i = 0; i < 10; i++;)
{
if (isnegative == 0)
{
i = i;
isnegative = 0;
}
else
{
i = i * (-1);
isnegative = 1;
}
Console.WriteLine(i);
}
}
}