Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit c8ff386

Browse files
committed
Make Random static
1 parent c7586e1 commit c8ff386

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

UniqueFileGenerator/RandomStringFactory.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed class RandomStringFactory
1818
/// </summary>
1919
private string CharacterBank { get; }
2020

21-
private Random Random { get; } = new();
21+
private static Random Random { get; } = new();
2222

2323
/// <summary>
2424
/// Constructor that populates the character bank.
@@ -73,11 +73,16 @@ public string CreateUniqueString(int length)
7373

7474
var outputChars = new char[length];
7575

76-
for (var i = 0; i < outputChars.Length; i++)
77-
{
78-
outputChars[i] = CharacterBank[Random.Next(CharacterBank.Length)];
79-
}
76+
//for (var i = 0; i < outputChars.Length; i++)
77+
//{
78+
// outputChars[i] = CharacterBank[Random.Next(CharacterBank.Length)];
79+
//}
80+
81+
Enumerable.Range(0, outputChars.Length)
82+
.ToList()
83+
.ForEach(i =>
84+
outputChars[i] = CharacterBank[Random.Next(CharacterBank.Length)]);
8085

8186
return new string(outputChars);
8287
}
83-
}
88+
}

0 commit comments

Comments
 (0)