what is output parameters?
Sarbeswar Sahoo
A return statement can be used for returning only one value from a function. you can return two values from a function. Output parameters are similar to reference parameters, except that they transfer data out of the method rather than into it.
In C#,It's a method parameter. Specially used for returning multiple values from method. And variables passed as out arguments do not have to be initialized at the time of calling that method but It must be initialized within that function body.
If you want your function to return more than one value then we use out parameters.
use out parameter if your function want to return more than one value
A parameter declared with an out modifier is an output parameter. Similar to a reference parameter, an output parameter does not create a new storage location. Instead, an output parameter represents the same storage location as the variable given as the argument in the method invocation.
Out is used to return value
It is useful, when you need to return values from a method through the parameters without assigning an initial value to the parameters.
Out parameters returns the values
output parameters returns the values
In c# when you use out parameters data passed in an unidirectional way.
A method is returning only one value. if you want to return more than one value from method then you can use either out or ref parameter. it is not necessary to initialize the value at declare time. so you can just pass the parameter in the method and after some manipulation , out param value will change after called method.
Every output parameter of a method must be definitely assigned before the method returns. Output parameters are typically used in methods that produce multiple return values.
Output parameters are used to receive the data the from any method.
Output parameters are used when you want to return multiple values from a function. Normally you can return only one value but defining multiple out parameters in your arguments defines how many values you can return...for example three out parameters in arguments means you can return three values from a function. Those are also not necessary to be initialized before like how we have to do for ref parameters.
it is used to passed argument by refrence, it is best purpose is if you want 2 return values form function.