Functions to generate 10 digits random numbers in c#


Functions to generate 10 digits random numbers in c#

Function 1-

        public static int NewKey()
        {
            Random ran = new Random(DateTime.Now.Millisecond);
            int key = 0;
            key = ran.Next(1000000000, int.MaxValue);
            return key;
        }


Function 2-


public static string GetTenDigitRandomNumber()
{
  Random generator = new Random();
  return generator.Next(0, 1000000).ToString("D10");
}