Are there any substantial side effects or downfalls to using the out parameter in C#? And would I be able to return two or more objects back?
I am new to C# and I have never returned values for a method through it's parameters. I thought it was quite useful when you need to return more than 1 object, but I want to make sure there are no major downfalls to doing this.
static int doubleScore(out int i, int score)
{
return score*2;
}
static void Main()
{
int score = 10;
int newScore = 0;
doubleScore(out newScore, score);
// newScore = 20
}
compared to:
static int doubleScore(int score)
{
return score*2;
}
static void Main()
{
int newScore = 0;
int score = 10;
newScore = doubleScore(score);
// newScore is now 20
}