diff --git a/VL250113_TryParse/TryParse.cs b/VL250113_TryParse/TryParse.cs index d94f4ab5f9cb9af37ba44159b949fc72f706910b..08cb0c054cad06c35ebfeab1b74b688d2d3c0ba5 100644 --- a/VL250113_TryParse/TryParse.cs +++ b/VL250113_TryParse/TryParse.cs @@ -1,6 +1,8 @@ class Program { // ConvertToInt oder IntParse + // Hier noch erweitert um die Basis des Zahlensystems. + // Funktioniert mit basis=2 oder 8 auch für Binär- und Oktalsystem public static int IntParse(string text, int basis=10) { int ergebnis = 0; @@ -55,8 +57,8 @@ int zahl1 = IntParse("5432"); Console.WriteLine($"zahl1 = {zahl1}"); - // int zahl2 = IntParse("54a3"); - //Console.WriteLine($"zahl2 = {zahl2}"); + int zahl2 = IntParse("1101", basis:2); + Console.WriteLine($"zahl2 = {zahl2}"); if (IntTryParse2("54a3", out int zahl3)) Console.WriteLine($"zahl3 = {zahl3}");