C
C#16mo ago
HD-Fr0sT

How do i make a random a static?

got any tips?
No description
6 Replies
Angius
Angius16mo ago
What are you trying to do, exactly?
HD-Fr0sT
HD-Fr0sTOP16mo ago
a random number that is random once and is the same value and later will be random again
Angius
Angius16mo ago
Store it outside of the loop, then So it won't change inside of it
MODiX
MODiX16mo ago
Angius
REPL Result: Success
int rnd = Random.Shared.Next(0, 10);
for (int i = 0; i < 5; i++)
{
Console.WriteLine(rnd);
}
int rnd = Random.Shared.Next(0, 10);
for (int i = 0; i < 5; i++)
{
Console.WriteLine(rnd);
}
Console Output
8
8
8
8
8
8
8
8
8
8
Compile: 356.685ms | Execution: 61.274ms | React with ❌ to remove this embed.
Angius
Angius16mo ago
As you can see, always the same
HD-Fr0sT
HD-Fr0sTOP16mo ago
i am severly brain dead

Did you find this page helpful?