mirror of https://github.com/oliverbooth/X10D
(#42) Validate count >=0
This commit is contained in:
parent
e8ef1cd028
commit
e3d38a633d
|
@ -1,4 +1,6 @@
|
||||||
namespace X10D
|
using System;
|
||||||
|
|
||||||
|
namespace X10D
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extension methods for <see cref="char" />.
|
/// Extension methods for <see cref="char" />.
|
||||||
|
@ -15,7 +17,12 @@
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public static string Repeat(this char value, int count)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue