Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Method return with multiple different types of variables

I'm trying to create a text-based rpg in C#, and I'm working on the controls. Basically, the player inputs a line, the program uses a method to read it to see what its supposed to do, and updates the proper variable. For example, if the player enters "go north" the program will write "You go North." and then add 1 to y for a coordinates system. at first I tried to define x and y in the method itself, but quickly learned it would reset the x and y back to 0 each time the method is called. Now I have the variables defined in main and the method grabs the players input, x and y. Now I have to return x and y, but I ran into a problem. trying to change the return value to int causes an error, I'm assuming because the players input is a string value, and I'm not sure how to return the x and y, while still giving the method the players input (string).

Sign In or Register to comment.