Get Random Number - CSharp System

CSharp examples for System:Random

Description

Get Random Number

Demo Code


using System.Web;
using System.Collections.Generic;
using System;//from  w ww.j  av  a2  s  .  c om

public class Main{
        public static string GetRandNumber(int lenght)
        {
            string randNumber = "";
            var ra = new Random();
            for (int i = 0; i < lenght; i++)
            {
                randNumber += (ra.Next(1,10) - 1).ToString();
            }
            return randNumber;
        }
}

Related Tutorials