Class RandomHelper
A shortcut to use
Inheritance
Namespace: Volo.Abp
Assembly: Volo.Abp.Core.dll
Syntax
public static class RandomHelper : object
Methods
GenerateRandomizedList<T>(IEnumerable<T>)
Generates a randomized list from given enumerable.
Declaration
public static List<T> GenerateRandomizedList<T>(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | items | items |
Returns
Type | Description |
---|---|
List<T> |
Type Parameters
Name | Description |
---|---|
T | Type of items in the list |
GetRandom()
Returns a nonnegative random number.
Declaration
public static int GetRandom()
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to zero and less than |
GetRandom(Int32)
Returns a nonnegative random number less than the specified maximum.
Declaration
public static int GetRandom(int maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | maxValue | The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to zero. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to zero, and less than maxValue; that is, the range of return values ordinarily includes zero but not maxValue. However, if maxValue equals zero, maxValue is returned. |
GetRandom(Int32, Int32)
Returns a random number within a specified range.
Declaration
public static int GetRandom(int minValue, int maxValue)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | minValue | The inclusive lower bound of the random number returned. |
System.Int32 | maxValue | The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer greater than or equal to minValue and less than maxValue; that is, the range of return values includes minValue but not maxValue. If minValue equals maxValue, minValue is returned. |
GetRandomOf<T>(T[])
Gets random of given objects.
Declaration
public static T GetRandomOf<T>(params T[] objs)
Parameters
Type | Name | Description |
---|---|---|
T[] | objs | List of object to select a random one |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | Type of the objects |
GetRandomOfList<T>(IList<T>)
Gets random item from the given list.
Declaration
public static T GetRandomOfList<T>(IList<T> list)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | list | List of object to select a random one |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | Type of the objects |