From 68310609b726883d7178a38e6d217c83263ab44f Mon Sep 17 00:00:00 2001 From: maxluli Date: Mon, 30 May 2022 15:26:03 +0200 Subject: [PATCH] Fixed a bug with the Hexadecimal color selector --- Paint_2/Form1.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Paint_2/Form1.cs b/Paint_2/Form1.cs index 6279a7d..389e76c 100644 --- a/Paint_2/Form1.cs +++ b/Paint_2/Form1.cs @@ -128,13 +128,14 @@ namespace Paint_2 private void btnSetColor_Click(object sender, EventArgs e) { string value = tbxColorHex.Text; + int fromBase = 16; value = value.Replace("#", String.Empty); int R, G, B; try - { - R = Convert.ToInt32(value[0] + value[1]); - G = Convert.ToInt32(value[2] + value[3]); - B = Convert.ToInt32(value[4] + value[5]); + { + R = Convert.ToInt32(String.Concat(value[0], value[1]), fromBase); + G = Convert.ToInt32(String.Concat(value[2], value[3]), fromBase); + B = Convert.ToInt32(String.Concat(value[4], value[4]), fromBase); } catch (Exception exception) {