//This one's just plain dumb. But it does teach one interesting fact about System.Random, in that it apparently //pre-rolls about fifty numbers. /// <summary> /// Returns the last number determined by the RNG, without rolling a new one. /// </summary> /// <returns> /// A 32-bit signed integer greater than or equal to zero and less than System.Int32.MaxValue. /// </returns> public static int ExtractSeed() { var randomType = rand.GetType(); var bindings = System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance; var nullObject = new object[] { }; var inext = (int)randomType.InvokeMember("inext", bindings, null, rand, null); var seedArray = (int[])randomType.InvokeMember("SeedArray", bindings, null, rand, null); return(seedArray[inext]); }