Add project data
This commit is contained in:
25
Tabletop.Core/Extensions/StringExtensions.cs
Normal file
25
Tabletop.Core/Extensions/StringExtensions.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace Tabletop.Core.Extensions
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a random string
|
||||
/// </summary>
|
||||
/// <param name="length">The length of the random string</param>
|
||||
/// <returns></returns>
|
||||
public static string RandomString(int length)
|
||||
{
|
||||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
var stringChars = new char[length];
|
||||
var random = new Random();
|
||||
|
||||
for (int i = 0; i < stringChars.Length; i++)
|
||||
{
|
||||
stringChars[i] = chars[random.Next(chars.Length)];
|
||||
}
|
||||
|
||||
var finalString = new string(stringChars);
|
||||
return finalString;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user