out parameter c# code example
Example 1: out parameters c#
int initializeInMethod;
OutArgExample(out initializeInMethod);
Console.WriteLine(initializeInMethod);
void OutArgExample(out int number)
{
number = 44;
}
Example 2: c# out argument
myMethod(out Task output);
output.Start();
Task output;
myMethod(out output);
output.Start();
Example 3: passing _ as out variable c#
What is _ in C#?
The underscore character ( _ ) is used to indicate that the parameter
should be ignored. It's like it is the write-only parameter.
It's also allowed to discard a variable type.
Discards could be used to ignore more parameters at once.