Member-only story
C# Out Parameter with Examples
The out keyword is used to declare output parameters in method or function signatures. The output parameter is a parameter that is used to return multiple values from a method. The output parameters are used to pass data out of a method. But a normal function is used for passing the data inside function.
out Parameter: Example
returnType methodName(parameters, out dataType outputParameter)
{
// Method body
// The method assigns a value to outputParameter
// ...
}
Basic Structure Of out Parameter
Output Parameter:
An out parameter is an output parameter, which means its value is expected to be set by the method. When the method is called, it must assign a value to the out parameter before the method returns.
Initialization Not Required:
Unlike regular parameters, you don’t need to initialize an out parameter before passing it to the method. The method is responsible for initializing it.
Multiple Outputs:
It is an option variable that you passed in function between parentheses () and and may include one or more parameter declarations, separated by commas.Each parameter consists of a data type and a parameter…