Random Phone Number - CSharp System

CSharp examples for System:Random

Description

Random Phone Number

Demo Code


using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  ww w.j av a2  s  .c o m*/

public class Main{
        public static string RandomPhoneNumber()
        {
            var sb = new StringBuilder();

            sb.Append("(");
            sb.Append(DataHelper.RandomNumber(3));
            sb.Append(") ");
            sb.Append(DataHelper.RandomNumber(3));
            sb.Append("-");
            sb.Append(DataHelper.RandomNumber(4));

            return sb.ToString();
        }
        public static int RandomNumber(int minValue, int maxValue)
        {
            var random = new Random();

            return random.Next(minValue, maxValue);
        }
        public static int RandomNumber(int maxValue)
        {
            return DataHelper.RandomNumber(0, maxValue);
        }
}

Related Tutorials