diff --git a/RandomExtentions.md b/RandomExtentions.md new file mode 100644 index 0000000..808e1b0 --- /dev/null +++ b/RandomExtentions.md @@ -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 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 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\ + * Description: Returns a random bool using the "Random" class + * Parameters: `this Random random`, `IEnumerable 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 + ``` \ No newline at end of file