Best practice to return multiple variables from a method

Soldato
Joined
22 Oct 2005
Posts
2,803
Location
Moving...
I've inherited some code that runs automated tests using Selenium, NUnit and C#.

I've noticed there's lot of repeated code in some tests where the same calculations are done in multiple tests. It makes sense to me to move this calculation to a separate method to avoid duplicating code.

The problem I have is that (in my head at least) the ideal solution is to pass this new method two variables, then have the method do some fancy calculations and return four variables. However, it looks like methods are only designed to return single variables.

Is there a way to return multiple variables from a method, or am I approaching things the wrong way? All the variables (in these tests at least) are defined locally within the test rather than globally.

As you can tell I'm a bit of a novice so am looking to do things the correct way rather than just bodge something together!
 
Back
Top Bottom