This article introduces new features of out parameter in C# 7.0. C# out parameter is used when a method returns multiple values. When a parameter passes with the Out keyword/parameter in the method, then that method works with the same variable value that is passed in the method call. If variable value changes, the method parameter value also changes.
There are some additional features of C# Out parameter
- Out parameter can pass without its declaration and initialization.
- Out parameter can use var type in the method parameter list.
- It is not obligatory that Out parameter name should be same in both function definition and call.
This article elaborates about improved features of Out parameter with the help of examples. So, let’s see each one by one.
In-line declaration of Out paramater
In the earlier C# versions, we would need to separate the declaration and initialization of the Out variable into two different statements. C# 7.0 provides this feature that the Out parameter can pass without its declaration and initialization. Let’s see an example.
using System;
using static System.Console;
namespace OutExample
{
class Program
{
static void Main(string[] args)
{
WriteLine("Please enter radious for circle");
double radious = Convert.ToDouble(ReadLine());
double circumference = CalculateCircle(radious, out double area);
WriteLine($"Circle's circumference is {circumference}");
WriteLine($"Circle's Area is {area}");
ReadKey();
}
static double CalculateCircle(double radious, out double area)
{
area = Math.PI * Math.Pow(radious, 2);
double circumference = 2 * Math.PI * radious;
return circumference;
}
}
}
Now, run this program. The result shows as per the following figure.

Figure 1: Output
This code shows the following features about Out parameter.
- A method can have one or more than one Out parameter.
- When using a method which has Out parameter, you don’t need to declare and initialize that Out parameter before.
The Out parameter can declare in-line at the time of method call such as area parameter.double circumference = CalculateCircle(radious, out double area);
- The in-line declared Out parameter can be accessed in the same block. Its scope is in the method where it calls.
- The called method is required to assign a value to Out parameter before the method returns.
- The method can be overloaded based on Out parameters.
- Async methods don’t have out parameter.
- Iterator methods don’t have out parameter.



Harish PaudelPosted Apr 7, 2020, 10:50 AM
How its check the age is > 18
Guest UserPosted Jul 6, 2019, 4:31 AM
Thanks.It's a good explaination
Saravanakumar SekaranPosted May 5, 2017, 5:37 AM
Wow very nice explanation
Hamid KhanPosted Apr 15, 2017, 10:13 AM
Can we use out parmeter in mvc controller
Ronalg QuinonesPosted Apr 12, 2017, 11:22 AM
Thanks to share :)
Rathrola Prem KumarPosted Apr 10, 2017, 9:07 PM
Excellent , Thanks for sharing Mr.Sandeep Singh :)
Pankaj Kumar ChoudharyPosted Apr 10, 2017, 9:01 PM
Hello Sandeep Sir Nice Explain. I think length of the longest subarray which contains numbers that can be arranged in a continuous sequence from an integer array is "4" and that is "57, 90, 92, 94", and i try your program and it returns "5" that is wrong. So check this and reply me if i get something wrong about your program