Witam. Kod jak poniżej. Za pomocą metidy get_choice nie jestes w stanie wyświetlić wartości zmiennej decision, mimo przypsiania jej wartości mychoice z metody getchoice. W czym tkwi pewnie banalny problem?
using System;
class Method
{
public static void Main()
{
Method method = new Method();
method.displayMenu();
method.Case();
method.get_Choice();
}
//display menu
void displayMenu()
{
Console.WriteLine("A-add new addres");
Console.WriteLine("D-delete adress");
Console.WriteLine("E-edit adress");
Console.WriteLine("Q-quit");
}
void get_Choice()
{
Method method1 = new Method();
string decision=method1.getChoice();
Console.WriteLine("Wybrałeś parametr" +decision);
Console.ReadLine();
}
string getChoice()
{
string myChoice;
myChoice = Console.ReadLine();
return myChoice;
}
void Case()
{
Method method2 = new Method();
string case1=method2.getChoice();
switch (case1)
{
case "a":
Console.WriteLine("New address will be added");
break;
case "d":
Console.WriteLine("Choosen adress will be deleted");
break;
case "e":
Console.WriteLine("Choosen adress will be edited");
break;
case "q":
Console.WriteLine("Quit command will be executed");
break;
default:
Console.WriteLine();
break;
}
Console.ReadLine();
}
}