Tuesday, July 14, 2015

Generate a random number


static public class Utility
    {
        static Random _rnd;

        static Utility()
        {
              // we need to keep an instance of Random around
              // so that we get a different number on each subsequent call
            _rnd = new Random(Environment.TickCount);
        }

        static public string GetRandomNumber()
        {
            return _rnd.Next(100000, 999999).ToString();
        }
    }