CSharp examples for System.Collections.Generic:IEnumerable
Random value from IEnumerable
using System.Reflection; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from w w w . java2 s .com*/ public class Main{ public static T Random<T>(this IEnumerable<T> enumerable) { var list = enumerable as IList<T> ?? enumerable.ToList(); return list.ElementAt(UnityEngine.Random.Range(0, list.Count())); } }