Created RandomExtentions (markdown)

Stone_Red
2021-05-10 17:37:32 +02:00
parent e77bf80a21
commit f76b68fcb4
+65
@@ -0,0 +1,65 @@
### Stone_Red_Utilities.RandomExtentions
#### Methods
* NextItem
* Description: Returns an random item from the specified collection using the Random class
* Parameters: `this Random random`, `IEnumerable<T> collection`
* Example usage:
```cs
string[] arr = { "test1", "test2", "test3" };
Random rnd = new Random();
string randomItem = rnd.NextItem(arr);
Console.WriteLine(randomItem);
```
* Output (Will be random every time):
```text
test2
```
* NextBool
* Description: Returns a random bool using the "Random" class
* Parameters: `this Random random`, `IEnumerable<T> collection`
* Example usage:
```cs
string[] arr = { "test1", "test2", "test3" };
Random rnd = new Random();
string randomItem = rnd.NextItem(arr);
Console.WriteLine(randomItem);
```
* Output (Will be random every time):
```text
test2
```
* NextEnum\<T>
* Description: Returns a random bool using the "Random" class
* Parameters: `this Random random`, `IEnumerable<T> collection`
* Example usage:
```cs
private enum MyEnum
{
a,
b,
c
}
...
Random rnd = new Random();
MyEnum randomItem = rnd.NextEnum(new MyEnum());
Console.WriteLine(randomItem);
```
* Output (Will be random every time):
```text
c
```