mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 02:25:41 +00:00
(#44) Replace string.Randomize overloads with optional parameter
This commit is contained in:
parent
4bf295a028
commit
f268cf5b02
@ -251,34 +251,14 @@ namespace X10D
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The pool of characters to use.</param>
|
/// <param name="source">The pool of characters to use.</param>
|
||||||
/// <param name="length">The length of the new string returned.</param>
|
/// <param name="length">The length of the new string returned.</param>
|
||||||
|
/// <param name="random">The <see cref="System.Random" /> supplier.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A new string whose length is equal to <paramref name="length" /> which contains randomly selected characters from
|
/// A new string whose length is equal to <paramref name="length" /> which contains randomly selected characters from
|
||||||
/// <paramref name="source" />.
|
/// <paramref name="source" />.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
/// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception>
|
/// <exception cref="ArgumentNullException"><paramref name="source" /> is <see langword="null" />.</exception>
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception>
|
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception>
|
||||||
public static string Randomize(this string source, int length)
|
public static string Randomize(this string source, int length, Random? random = null)
|
||||||
{
|
|
||||||
return source.Randomize(length, RandomExtensions.Random);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a new string of a specified length by randomly selecting characters from the current string.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="source">The pool of characters to use.</param>
|
|
||||||
/// <param name="length">The length of the new string returned.</param>
|
|
||||||
/// <param name="random">The <see cref="System.Random" /> supplier.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A new string whose length is equal to <paramref name="length" /> which contains randomly selected characters from
|
|
||||||
/// <paramref name="source" />.
|
|
||||||
/// </returns>
|
|
||||||
/// <exception cref="ArgumentNullException">
|
|
||||||
/// <paramref name="source" /> is <see langword="null" />.
|
|
||||||
/// -or-
|
|
||||||
/// <paramref name="random" /> is <see langword="null" />.
|
|
||||||
/// </exception>
|
|
||||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="length" /> is less than 0.</exception>
|
|
||||||
public static string Randomize(this string source, int length, Random random)
|
|
||||||
{
|
{
|
||||||
if (source is null)
|
if (source is null)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user