#if !NETCOREAPP3_1_OR_GREATER namespace System; /// /// A type with some helper methods for the class. /// internal static class RandomExtensions { /// /// Fills the elements of a specified span of bytes with random numbers. /// /// The target random instance. /// The array to be filled with random numbers. public static void NextBytes(this Random random, Span buffer) { byte[] array = new byte[buffer.Length]; random.NextBytes(array); array.AsSpan().CopyTo(buffer); } } #endif