public static void Input(int firstBase, int secondBase) w której ciele przetwarza dane z parametrów i wywołuje kolejne dwie inne metody. Do funkcji Input chciałem przekazać argumenty, jest to akurat opcja w instrukcji switch i prezentuję ją poniżej:
case ConsoleKey.D3: Console.Clear(); int firstBase = Console.Read(); int secondBase = Console.Read(); Input(firstBase, secondBase); break; Niestety po podaniu firstBase od razu wywołuje się kolejna funkcja, do której odwołanie istnieje właśnie w metodzie Input.
public static void Input(int firstBase, int secondBase) { Console.Clear(); String nvalue = Console.ReadLine(); int jeden = firstMethod(nvalue, firstBase); string dwa = secondMethod(jeden, secondBase); Błąd jest zapewne banalny, ale nie ogarniam, dlaczego nie można wprowadzić drugiej wartości we switchu.
@grap32: Console.Read zwraca int tak samo jak Convert.ToInt32 dokumentacja mówi: Returns the specified 32-bit signed integer; no actual conversion is performed.
public static void Input(int firstBase, int secondBase)w której ciele przetwarza dane z parametrów i wywołuje kolejne dwie inne metody.
Do funkcji Input chciałem przekazać argumenty, jest to akurat opcja w instrukcji switch i prezentuję ją poniżej:
case ConsoleKey.D3:Console.Clear();
int firstBase = Console.Read();
int secondBase = Console.Read();
Input(firstBase, secondBase);
break;
Niestety po podaniu firstBase od razu wywołuje się kolejna funkcja, do której odwołanie istnieje właśnie w metodzie Input.
public static void Input(int firstBase, int secondBase){
Console.Clear();
String nvalue = Console.ReadLine();
int jeden = firstMethod(nvalue, firstBase);
string dwa = secondMethod(jeden, secondBase);
Błąd jest zapewne banalny, ale nie ogarniam, dlaczego nie można wprowadzić drugiej wartości we switchu.
#csharp #naukaprogramowania
Read czyta tylko 1 znak, pewnie chcesz zrobić readline.
@Yahoo_: @Sierpik21: zrobiłem Convert.ToInt32(Console.Read())
Returns the specified 32-bit signed integer; no actual conversion is performed.
https://docs.microsoft.com/pl-pl/dotnet/api/system.convert.toint32?view=netframework-4.7.2
Convert.ToInt32(Console.ReadLine());
Pozdro