diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs index b843bba569..97992ad27d 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/RandomHelper.cs @@ -72,6 +72,18 @@ namespace Volo.Abp return objs[GetRandom(0, objs.Length)]; } + /// + /// Gets random item from the given list. + /// + /// Type of the objects + /// List of object to select a random one + public static T GetRandomOf([NotNull] IList list) + { + Check.NotNullOrEmpty(list, nameof(list)); + + return list[GetRandom(0, list.Count)]; + } + /// /// Generates a randomized list from given enumerable. ///