feyris-tan ef86554f9a Import
2025-05-12 22:09:16 +02:00

26 lines
583 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SDL2Demo.Screenhacks
{
internal static class RandomExtensions
{
public static T? Pick<T>(this Random rng, T[] collection)
{
if (collection == null)
return default(T);
if (collection.Length == 0)
return default(T);
if (collection.Length == 1)
return collection[0];
return collection[rng.Next(collection.Length)];
}
}
}