C#C
C#3y ago
drewhosick

Why Do you have to Create an instance of a Class in some cases for methods and not others?

I was trying to program the usual Random Number Generator earlier today as a guessing game. I kept running into an issue because I tried Random.Next(1,10); and it was spitting out an error. I then found an example of the code and it was having me create the line Random rnd = new Random(); and then I could use rnd.Next(1,10). Why is it that I can't use Random.Next but in other situations I can do something like variable.Length(); I'm confused as to why it's making me create an instance of a Random object to use a method but not when using things like Length or Convert.ToInt32();
Was this page helpful?