Within a switch function in a method, I get an error "The name 'Radius' does not exist in the current context." The varible is assigned elsewhere in the code. I don't get the error for the other variables.
Code:
public static double MenuItem(int amount) // method based on menu selection
{
double Volume;
// double Radius;
double Number = Radius;
// if (amount < 1 || amount > 3)
// amount = 4;
switch (amount)
{
case 1:
Volume = 4 / 3 * Math.PI * Math.Pow (Radius, 3);
break;
case 2:
double Length, Width, Height;
Volume = Length * Width * Height;
break;
case 3:
Volume = Math.PI * Math.Pow (Radius, 2) * Height;
break;
default:
Console.WriteLine("Your response was out of the expected range");
Volume = 0;
//Radius = 1;
//Length = 1;
//Width = 1;
//Height = 1;
break;
}
Console.WriteLine("");
return Volume;
}
Comment