Pip-Services-Commons-Dotnet
Static Public Member Functions | Static Private Attributes | List of all members
PipServices3.Commons.Random.RandomString Class Reference

Random generator for string values. More...

Static Public Member Functions

static char Pick (string values)
 Picks a random character from a string. More...
 
static string Pick (String[] values)
 Picks a random character from an array of string.. More...
 
static string Distort (string value)
 Distorts a string by randomly replacing characters in it. More...
 
static char NextAlphaChar ()
 Generates random alpha characted [A-Za-z] More...
 
static string NextString (int minLength, int maxLength)
 Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits(0-9), and symbols("_,.:-/.[].{},#-!,$=%.+^.&*-() "). More...
 

Static Private Attributes

static readonly string _digits = "01234956789"
 
static readonly string _symbols = "_,.:-/.[].{},#-!,$=%.+^.&*-() "
 
static readonly string _alphaLower = "abcdefghijklmnopqrstuvwxyz"
 
static readonly string _alphaUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 
static readonly string _alpha = _alphaUpper + _alphaLower
 
static readonly string _chars = _alpha + _digits + _symbols
 

Detailed Description

Random generator for string values.

var value1 = RandomString.Pick("ABC"); // Possible result: "C"
var value2 = RandomString.Pick(new String {"A","B","C"}); // Possible result: "B"

Member Function Documentation

◆ Distort()

static string PipServices3.Commons.Random.RandomString.Distort ( string  value)
static

Distorts a string by randomly replacing characters in it.

Parameters
valuea string to distort.
Returns
a distored string.

◆ NextAlphaChar()

static char PipServices3.Commons.Random.RandomString.NextAlphaChar ( )
static

Generates random alpha characted [A-Za-z]

Returns
a random characted.

◆ NextString()

static string PipServices3.Commons.Random.RandomString.NextString ( int  minLength,
int  maxLength 
)
static

Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits(0-9), and symbols("_,.:-/.[].{},#-!,$=%.+^.&*-() ").

Parameters
minLength(optional) minimum string length.
maxLengthmaximum string length.
Returns
a random string.

◆ Pick() [1/2]

static char PipServices3.Commons.Random.RandomString.Pick ( string  values)
static

Picks a random character from a string.

Parameters
valuesa string to pick a char from
Returns
a randomly picked char.

◆ Pick() [2/2]

static string PipServices3.Commons.Random.RandomString.Pick ( String []  values)
static

Picks a random character from an array of string..

Parameters
valuesa string to pick from
Returns
a randomly picked string.

The documentation for this class was generated from the following file: