From e3d38a633dc3426a2d6320dfe7cfff9529cb2b1f Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Sun, 27 Jun 2021 13:11:03 +0100 Subject: [PATCH] (#42) Validate count >=0 --- X10D/src/CharExtensions/CharExtensions.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/X10D/src/CharExtensions/CharExtensions.cs b/X10D/src/CharExtensions/CharExtensions.cs index dae9639..73c36f1 100644 --- a/X10D/src/CharExtensions/CharExtensions.cs +++ b/X10D/src/CharExtensions/CharExtensions.cs @@ -1,4 +1,6 @@ -namespace X10D +using System; + +namespace X10D { /// /// Extension methods for . @@ -15,7 +17,12 @@ /// public static string Repeat(this char value, int count) { - return new(value, count); + if (count < 0) + { + throw new ArgumentOutOfRangeException(nameof(count), ExceptionMessages.CountMustBeGreaterThanOrEqualTo0); + } + + return new string(value, count); } } }