| 123456789101112131415161718192021 |
- using System;
- namespace Quadarax.Foundation.Core.Value.Extensions
- {
- public static class RandomExt
- {
- public static bool NextBool(this Random owner, int truePercentage)
- {
- if (owner == null)
- throw new ArgumentNullException(nameof(owner));
- if (truePercentage == 0)
- return false;
- if (truePercentage >= 100)
- return true;
- var value = owner.Next(0, 100);
- return value <= truePercentage;
- }
- }
- }
|