#the program includes: random number generation + input from player + bigger/smaller comparisons between numbers +
Explore tagged Tumblr posts
racke7 · 1 year ago
Text
Spent like four hours this morning creating a "guess the random number" game from scratch in C#.
It argued with me basically the entire way (this is the first program I've really created, so not very surprising), but the worst part was trying to track down a way to get a "random number", because everything I looked into either didn't work or did something different.
Finally managed to modify one idea and create a method (1 random number, between 1-100), which I'm recording here for future (emergency) reference:
class MyClass { public int GenerateRandom () { Random randomNumber = new Random(); for (int ctr = 0; ctr <= 0; ctr++); return randomNumber.Next(101); } }
Is it the best way? No idea. But it's the only way that worked, and it works pretty okay? So, I'm pretty happy with it.
1 note · View note