drewhosick
Damned Arrays
I've been trying since yesterday to figure out what I'm doing wrong. I try to initialize a multidimentional array in a method inside a class and then fill it using a double for loop. Trying to fill it all with # characters. I know if I take out the word public it seems to have less errors but then I can't access it outside of the method. I assume I could pass it out as a return but I was hoping I could just access it directly for now. With the public word in front it gives me a whole bunch of errors. I assume I have the syntax wrong somewhere or I'm doing something I can't do inside of a method but don't know why.
16 replies
accessing an instance of a class in another class
How do you access an instance of a class variable or method if you need to access it from another class? I created the instance in the main program. Do I have to pass it all as arguments and then assign it to another instance of the class created in the method of the other class or is there a better way?
20 replies
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();
16 replies