Created
May 15, 2014 12:25
-
-
Save eduardosilva/ceb0225abdcb3bc5b0c3 to your computer and use it in GitHub Desktop.
Random Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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