I am making a program to switch to different Algorithms. I would love to know if you could reuse variables in a switch statement.
I have tried looking it up and changing to global and final but nothing seems to work
enter code here
switch(nr){
case 1: //For one algorithm
Console.Write("Write your base: ")
double b = convert.ToInt32(Console.Readline())
break;
case 2: //For the second algorithm but with the same name on the variable
Console.Write("Write your second base: ")
double b = convert.ToInt32(Console.Readline()) <<<<< //ERROR on this line
break;
}
I did not expect this too happen due to its different cases
struct System.Double
Represents a double-precision floating point number