RandomExtensionsNextString(Random, Int32, Int32, StringCreation) Method

Returns a random String using the specified strategy that has the length between the specified range.


Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 7.0.0-rc.1
public static string NextString(
	this Random random,
	int minLength,
	int maxLength,
	StringCreation strategy = StringCreation.Ascii


random  Random
The Random instance to use.
minLength  Int32
The inclusive lower bound of the length of the returned string.
maxLength  Int32
The inclusive upper bound of the length of the returned string. Must be greater or equal to minLength.
strategy  StringCreation  (Optional)
The strategy to use. This parameter is optional.
Default value: Ascii.

Return Value

A String value generated by the specified strategy that has the length greater than or equal to minLength and less and less or equal to maxLength.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Random. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).


ArgumentNullExceptionrandom is .
ArgumentOutOfRangeExceptionminLength is less than 0 or maxLength is less than minLength
strategy is not a valid value of StringCreation.

See Also