-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelper.cs
More file actions
36 lines (28 loc) · 861 Bytes
/
Helper.cs
File metadata and controls
36 lines (28 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace di320fm
{
static class Helper
{
public static string RandomString(int length)
{
if (length == 0)
return String.Empty;
if (length < 0)
throw new ArgumentOutOfRangeException("length", "cannot be negative");
var charArray = new char[length];
//48 90
const int lowerBound = (int)'A';
const int upperBound = (int)'Z';
var rnd = new Random(Guid.NewGuid().GetHashCode());
for (var i = 0; i < charArray.Length; i++)
{
charArray[i] = (char) rnd.Next(lowerBound, upperBound + 1);
}
return new string(charArray);
}
}
}