Method GetRandom
GetRandom()
Returns a random element from the Set.
Declaration
T GetRandom()
Returns
Type | Description |
---|---|
T | Random element from the Set. |
Examples
The following code sample shows how to get random element from Distributed Set.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedSet";
IDistributedHashSet<int> set = cache.DataTypeManager.GetHashSet<int>(dataTypeName);
int result = set.GetRandom();
GetRandom(Int32)
Returns count distinct random elements from the Set.
Declaration
T[] GetRandom(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | Number of required elements. |
Returns
Type | Description |
---|---|
T[] | Count distinct elements from the Set. |
Examples
The following code sample shows how to get random elements from a Distributed Set.
ICache cache = CacheManager.GetCache("demoClusteredCache");
string dataTypeName = "DistributedSet";
IDistributedHashSet<int> set = cache.DataTypeManager.GetHashSet<int>(dataTypeName);
int[] result = set.GetRandom(5);