• Webinars
  • Docs
  • Download
  • Blogs
  • Contact Us
Try Free
Show / Hide Table of Contents

Method GetRandom

GetRandom()

// Return a random element from the set.

Declaration
T GetRandom()
Returns
Type Description
T

Random element from set.

Examples

The following code sample shows how to get random element from distributed set.

 ICache cache = CacheManager.GetCache("demoCache");
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 set.

Examples

The following code sample shows how to get random elements from distributed set.

 ICache cache = CacheManager.GetCache("demoCache");
string dataTypeName = "DistributedSet";

IDistributedHashSet<int> set = cache.DataTypeManager.GetHashSet>int>(dataTypeName);

int[] result = set.GetRandom(5);
Back to top Copyright © 2017 Alachisoft