How to generate a random integer in C#?
Hi everyone! I'm a beginner in C#, and I'm having trouble with random number generation. I need to create a simple game where the computer picks a number from 1 to 100, and the user has to guess it. But I can't figure out how to properly get a random integer.
I tried using the Random class, but I'm getting something strange. Here's my code:
```csharp
Random random = new Random();
int secretNumber = random.Next();
Console.WriteLine(secretNumber);
```
The problem is that this number turns out to be huge (e.g., 1234567890), but I need it strictly from 1 to 100. I've read that Random has a Next() method that takes parameters, but I'm not sure how to use them correctly.
Also, I noticed that if I create a new Random each time in a loop, the numbers repeat. For example