From 4a0f9b852becb7e10a9aa8e4bfe5fbdf514d30cb Mon Sep 17 00:00:00 2001 From: Jens Albrecht <jens.albrecht@th-nuernberg.de> Date: Mon, 13 Jan 2025 16:52:52 +0100 Subject: [PATCH] . --- VL250113_TryParse/TryParse.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/VL250113_TryParse/TryParse.cs b/VL250113_TryParse/TryParse.cs index d94f4ab..08cb0c0 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}"); -- GitLab