PKHeX/PKHeX.Core/Util/RandUtil.cs
Kurt d47bb1d297
Update .NET Runtime to .NET 8.0 (#4082)
With the new version of Visual Studio bringing C# 12, we can revise our logic for better readability as well as use new methods/APIs introduced in the .NET 8.0 BCL.
2023-12-03 20:13:20 -08:00

12 lines
375 B
C#

using System;
namespace PKHeX.Core;
public static partial class Util
{
public static Random Rand => Random.Shared;
public static uint Rand32() => Rand32(Rand);
public static uint Rand32(this Random rnd) => ((uint)rnd.Next(1 << 30) << 2) | (uint)rnd.Next(1 << 2);
public static ulong Rand64(this Random rnd) => rnd.Rand32() | ((ulong)rnd.Rand32() << 32);
}