1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:18:47 +00:00

(#42) Validate count >=0

This commit is contained in:
Oliver Booth 2021-06-27 13:11:03 +01:00
parent e8ef1cd028
commit e3d38a633d

View File

@ -1,4 +1,6 @@
namespace X10D
using System;
namespace X10D
{
/// <summary>
/// Extension methods for <see cref="char" />.
@ -15,7 +17,12 @@
/// </returns>
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);
}
}
}