mirror of
https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities.git
synced 2026-09-06 00:15:59 +02:00
Updated RandomExtentions (markdown)
+7
-8
@@ -22,25 +22,24 @@
|
||||
|
||||
* NextBool
|
||||
* Description: Returns a random bool using the "Random" class
|
||||
* Parameters: `this Random random`, `IEnumerable<T> collection`
|
||||
* Parameters: `this Random random`
|
||||
* Example usage:
|
||||
|
||||
```cs
|
||||
string[] arr = { "test1", "test2", "test3" };
|
||||
Random rnd = new Random();
|
||||
string randomItem = rnd.NextItem(arr);
|
||||
Console.WriteLine(randomItem);
|
||||
string randomBool = rnd.NextBool();
|
||||
Console.WriteLine(randomBool);
|
||||
```
|
||||
|
||||
* Output (Will be random every time):
|
||||
|
||||
```text
|
||||
test2
|
||||
true
|
||||
```
|
||||
|
||||
* NextEnum\<T>
|
||||
* Description: Returns a random bool using the "Random" class
|
||||
* Parameters: `this Random random`, `IEnumerable<T> collection`
|
||||
* Parameters: `this Random random`, `Enum`
|
||||
* Example usage:
|
||||
|
||||
```cs
|
||||
@@ -54,8 +53,8 @@
|
||||
...
|
||||
|
||||
Random rnd = new Random();
|
||||
MyEnum randomItem = rnd.NextEnum(new MyEnum());
|
||||
Console.WriteLine(randomItem);
|
||||
MyEnum randomEnum = rnd.NextEnum(new MyEnum());
|
||||
Console.WriteLine(randomEnum);
|
||||
```
|
||||
|
||||
* Output (Will be random every time):
|
||||
|
||||
Reference in New Issue
Block a user