CSharp examples for System:Random
Random Number as string value
using System.Text; using System.Diagnostics; using System.Collections.Generic; using System;//w w w. ja v a2s. c om public class Main{ public static string RndNum(int codeNum) { StringBuilder sb = new StringBuilder(codeNum); Random rand = new Random(); for (int i = 1; i < codeNum + 1; i++) { int t = rand.Next(9); sb.AppendFormat("{0}", t); } return sb.ToString(); } }