Advertisement
Pro_Unit

GetRandom

Sep 3rd, 2019
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.26 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. // где-то в статическом классе
  4. public static T GetRandom<T> (this IEnumerable<T> collection)
  5. {
  6.     T[] array = collection.ToArray ();
  7.     return array[Random.Range (0, array.Length)];
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement