CSharp examples for System:Random
Generate Random String
using System.Threading.Tasks; using System.Text; using System.Linq; using System.Collections.Generic; using System;/*from ww w . j a va2s . c om*/ public class Main{ public static string GenerateRandomString(int length) { const string characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var random = new Random(DateTime.Now.Millisecond); var output = string.Empty; for(var i = 0; i < length; i ++) { output += characters[random.Next(characters.Length - 1)]; } return output; } }