The name 'quit' does not exist in the current context

I don't understand why my method does not see the quit variable. Isn't the boolean quit a wide scope variable available to all methods?

I tried putting it in a couple of places outside Main and inside main but I can not get a method to see it. Can someone explain to me what gives?

I get the error:

Error 1 An object reference is required for the nonstatic field, method, or property Program.quit'

bool quit =true;

staticvoid Main(string[] args)

{

do

{

getChoice();

}while (!quit);

}

publicstaticvoid getChoice()

{

quit =IO.GetChar("Choose a)square root, b)floor, c)absolute value, d)Quit: y or n ");

quit = (quit =='y');

}

Ok, I've rewritten it. But I still have this problem:

The name 'inputNmbr' does not exist in the current context

Even if I take the variable and place it under class rather than the Main method, I still have an error. Thanks in advance for any explanation or advice..

using System;
using System.Collections.Generic;
using System.Text;

namespace TTTTT
{
class Program
{

static void Main(string[] args)
{

char quit = 'y';
char choice;

do
{

quit = getChoice(quit);
if (quit != 'n' || quit != 'y')
{
choice = quit;
inputNmbr = IO.GetDouble("What number do you wish?: ");
doMath(choice);
}
} while (quit == 'n');

}

static char getChoice(char quit)
{
quit = IO.GetChar("Choose a)square root, b)floor, c)absolute value, d)Quit - y or n: ");
//quit = (quit == 'y');

return quit;
}

static char doMath(char choice)
{
switch (choice) {
case 'a':
Console.WriteLine("inputNmbr = ", inputNmbr = Math.Pow(inputNmbr, 2.0));
break;
case 'b':

break;
case 'c':

break;
}
}

}
}

[2554 byte] By [Foolios] at [2007-12-25]
# 1

for the first example you were trying to set the BOOLEAN value "quit" to a character - this won't work, different variable types. You may also need to declare bool as a static member:

private static bool quit = false;

the second example, you did not declare inputNmbr, declare it at the top as a global scope for example or just within that method if you dont need the other methods to see that variable. Example:

static void Main(string[] args)
{

char quit = 'y';
char choice;

double inputNmbr;

do
{

quit = getChoice(quit);
if (quit != 'n' || quit != 'y')
{
choice = quit;
inputNmbr = IO.GetDouble("What number do you wish?: ");
doMath(choice);
}
} while (quit == 'n');

}

ahmedilyas at 2007-10-8 > top of Msdn Tech,Visual Studio Express Editions,Visual C# 2005 Express Edition...