Random Number String by length - CSharp System

CSharp examples for System:String Parse

Description

Random Number String by length

Demo Code


using System.Net;
using System.IO;//from  w  w w .  j  a va 2 s.c  om
using System.Text.RegularExpressions;
using System.Web;
using System.Text;
using System.Collections.Generic;
using System;

public class Main{

        public static string RandomNumber(int RanLength)
        {
            string RanNum = string.Empty;
            char[] Nums = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

            Random r = new Random();
            for (int i = 0; i < RanLength; i++)
            {
                RanNum += Nums[r.Next(0, Nums.Length)].ToString();
            }

            return RanNum;
        }
}

Related Tutorials