I'm learning C# and am completely new to it so I'm sorry if this seems like a really simple question.
I've just watched a tutorial explaining how you can use the out
parameter to return multiple values from a method. However, I don't really understand how it works in practice. The example they gave is:
using System;
namespace UsingOut
{
class Program
{
static void Main(string[] args)
{
string statement = "GARRRR";
string murmur = Whisper(statement, out bool marker);
Console.WriteLine(murmur);
}
static string Whisper(string phrase, out bool wasWhisperCalled)
{
wasWhisperCalled = true;
return phrase.ToLower();
}
}
}
However, I don't see how this is returning multiple values? It looks like it's just returning the string?
Please can someone give me a really simple explanation of when to use out
and what it actually does?
Thanks so much