Skip to content

Instantly share code, notes, and snippets.

@eduardosilva
Created May 15, 2014 12:25
Show Gist options
  • Save eduardosilva/ceb0225abdcb3bc5b0c3 to your computer and use it in GitHub Desktop.
Save eduardosilva/ceb0225abdcb3bc5b0c3 to your computer and use it in GitHub Desktop.
Random Text
public static class RandomExtensions
{
public static string NextString(this Random source, int length)
{
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var result = new string(
Enumerable.Repeat(chars, length)
.Select(s => s[source.Next(s.Length)])
.ToArray());
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment