-
Notifications
You must be signed in to change notification settings - Fork 0
/
GlobalCus.cs
44 lines (34 loc) · 1.04 KB
/
GlobalCus.cs
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
37
38
39
40
41
42
43
44
namespace Banking_App
{
public class GlobalCus
{
public static string GenerateNumber(int count)
{
var random = new Random();
var randomIntegers = new int[count];
for (int i = 0; i < randomIntegers.Length; i++)
randomIntegers[i] = random.Next(0, 10);
return string.Join("", randomIntegers);
}
public static string GenerateId()
{
const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var charArr = chars.ToCharArray();
var random = new Random();
random.Shuffle(charArr);
return string.Join("", charArr)[..6];
}
}
static class RandomExtensions
{
public static void Shuffle<T>(this Random rng, T[] array)
{
int n = array.Length;
while (n > 1)
{
int k = rng.Next(n--);
(array[k], array[n]) = (array[n], array[k]);
}
}
}
}