Generate Random Number - CSharp System

CSharp examples for System:Random

Description

Generate Random Number

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from w  w  w. j  a v a2s . c o m*/

public class Main{
        public static string GenerateNumber(int n)
        {
            StringBuilder builer = new StringBuilder();
            Random rd = new Random();
            for (int i = 0; i < n; i++)
                builer.Append(constant[rd.Next(10)]);
            return builer.ToString();
        }
}

Related Tutorials