Skip to content

Instantly share code, notes, and snippets.

@cameronsjo
Created April 24, 2015 20:38
Show Gist options
  • Select an option

  • Save cameronsjo/47759c34089d6ca6c328 to your computer and use it in GitHub Desktop.

Select an option

Save cameronsjo/47759c34089d6ca6c328 to your computer and use it in GitHub Desktop.
public static string GenerateRandomString(int length = 10)
{
const string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmopqrstuvwxyz";
var r = new Random();
return new string(Enumerable.Repeat(alphabet, length)
.Select(s => s[r.Next(s.Length)])
.ToArray());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment