out Parameter
noun
say it: “OWT puh-RAM-uh-ter” /aʊt pəˈræmətər/
A parameter marked out that the method must set and hands back to the caller, so one call can give back more than one value.
What is an out Parameter in C#?
out Parameter — A parameter marked out: a value the method hands back to the caller, beside its return value. The method must set it before it ends, and the call writes out too, as int.TryParse does.
ShareSlices(17, 5, out int each, out int left);
Console.WriteLine(each + " each, " + left + " left"); // 3 each, 2 left
void ShareSlices(int slices, int people, out int perPerson, out int leftOver)
{
perPerson = slices / people;
leftOver = slices % people;
}
In a sentence
- “int.TryParse hands back the number through an out parameter and returns true or false.”
Level: Apprentice · More C# terms at this level
Updated