Class RandomEx
Class containing some extension methods for System.Random.
Inheritance
System.Object
RandomEx
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class RandomEx
Methods
| Improve this Doc View SourceCoinToss(Random)
Returns randomly true or false.
Declaration
public static bool CoinToss(this Random random)
Parameters
Type | Name | Description |
---|---|---|
System.Random | random | The random to use. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true or false (random value). |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | random can not be null. |
RandomOne<T>(Random, T[])
Returns randomly one of the given values.
Declaration
public static T RandomOne<T>(this Random random, params T[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Random | random | The random to use. |
T[] | values | A list of values. |
Returns
Type | Description |
---|---|
T | Returns randomly one of the given values. |
Type Parameters
Name | Description |
---|---|
T | The type of the values. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The random can not be null. |
System.ArgumentNullException | The values can not be null. |
RandomOne<T>(Random, IEnumerable<T>)
Returns randomly one of the given values.
Declaration
public static T RandomOne<T>(this Random random, IEnumerable<T> values)
Parameters
Type | Name | Description |
---|---|---|
System.Random | random | The random to use. |
System.Collections.Generic.IEnumerable<T><T> | values | A IEnumerable containing the values. |
Returns
Type | Description |
---|---|
T | Returns randomly one of the given values. |
Type Parameters
Name | Description |
---|---|
T | The type of the values. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The random can not be null. |
System.ArgumentNullException | The values can not be null. |