Click or drag to resize
RandomStringCharacters Method (IRandom, Char, Int32, Int32, Char, Char, Single, Boolean, Boolean, Boolean)
Fills a portion of a provided character buffer with random characters using the provided character set.

Namespace: Experilous.MakeItRandom
Assembly: Assembly-CSharp-firstpass (in Assembly-CSharp-firstpass.dll) Version: 0.0.0.0
Syntax
C#
public static void Characters(
	this IRandom random,
	char[] buffer,
	int start,
	int length,
	char[] characters,
	char separator,
	float separatorProbability,
	bool allowSeparatorAtEnd = false,
	bool allowSeparatorAtBegin = false,
	bool forceSeparatorAtBegin = false
)

Parameters

random
Type: Experilous.MakeItRandomIRandom
The pseudo-random engine that will be used to generate bits from which the return value is derived.
buffer
Type: SystemChar
The character buffer to which random charactors will be written.
start
Type: SystemInt32
The start index of the character buffer where random character generation will begin. Must be less than or equal to buffer.Length - length.
length
Type: SystemInt32
The number of random characters to be generated. Must be less than or equal to buffer.Length - start.
characters
Type: SystemChar
The allowable characters to select from when generating the string.
separator
Type: SystemChar
The separator character to be randomly inserted into the string according to the probability specified.
separatorProbability
Type: SystemSingle
The probability of any specific index in the string being a separator character. Must be in the range [0, 1].
allowSeparatorAtEnd (Optional)
Type: SystemBoolean
Whether or not the last character to be generated is allowed to be a separator character.
allowSeparatorAtBegin (Optional)
Type: SystemBoolean
Whether or not the first character to be generated is allowed to be a separator character.
forceSeparatorAtBegin (Optional)
Type: SystemBoolean
Whether or not the first character to be generated must be a separator character. Ignored if allowSeparatorAtBegin is false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IRandom. 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).
Remarks

It is guaranteed that two separator characters will never be generated one immediately after the other within the character sequence, regardless of the separator probability.

A separator probability of 0 will guarantee that there are no separators at all, while a probability of 1 will guarantee that every second character is a separtor character. Probabilities less than 1 but greater that 0.5 will be biased toward the same every-other character outcome, but will have a chance of generating longer sequences of non-separator characters, rather than being strictly limited to one non-separator character at a time.

See Also