SystemExt/Extensions/System.Random.cs
/// <summary>
/// Generates a random ASCII string with the specified length.
/// </summary>
/// <param name="self">
/// An instance of the <see cref="Random"/> class.
/// </param>
/// <param name="length">
/// The length of the string to generate.
/// </param>
/// <param name="printable">
/// Whether to only use characters which are printable.
/// </param>
/// <returns>
/// A new string containing <paramref name="length"/> random characters.
/// </returns>
Generates a random ASCII string with the specified length.
Generates a random ASCII string with the specified length .
public static string NextString(this Random self, byte length, bool printable = true)
        {
            var buffer = new byte[length];
            for (var pos = 0; pos < length; pos++)
            {
                buffer[pos] = (byte)(printable ? self.Next(33, 126) : self.Next(0, 255));
            }
            return Encoding.ASCII.GetString(buffer);
        }
public static string NextString ( this Random self , byte length , bool printable = true ) { var buffer = new byte [ length ] ; for ( var pos = 0 ; pos < length ; pos ++ ) { buffer [ pos ] = ( byte ) ( printable ? self . Next ( 33 , 126 ) : self . Next ( 0 , 255 ) ) ; } return Encoding . ASCII . GetString ( buffer ) ; }
Generates a random ASCII string with the specified length.
Generates a random ASCII string with the specified length .
A new string containing  random characters.
A new string containing random characters .
Random
this
length
byte
The length of the string to generate.
The length of the string to generate .
printable
bool
Whether to only use characters which are printable.
Whether to only use characters which are printable .
self
An instance of the  class.
An instance of the class .