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