---
title: "use of out parameter in c#"  
description: "use of out parameter in c#"  
author: "Sushant Mishra"  
published: 2017-08-25  
updated: 2017-08-25  
canonical: https://www.mindstick.com/forum/34334/use-of-out-parameter-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# use of out parameter in c#

i have little confujion in out [keyword](https://www.mindstick.com/forum/33572/sql-inner-join-keyword), where we use this, please give an example \

## Replies

### Reply by Niraj Kumar Mishra

when you are want to return any value from any method then you are use ***return*** keyword. But ***return*** keyword return only one value at a time.\
Let see in Example:

```
using System; class Program {  
   public static void Main()   {      int result = 0;      result = Add(10, 20);      Console.WriteLine("Sum={0} ", result);      Console.ReadKey();   }   
   public static int Add(int FN, int SN)   {     return FN + SN;   } }
```

\
in this example method *Add* return a single value.But at the same time i want to return more than one value from a method then *return* not do this operation.So, that place we use ***out*** keyword.Because ***out*** keyword used when you want a method to return more than one value.Let see in below example**Example:** I have a method ***Calculate*** and i want to it return two value first is ***Sum*** and second is ***Subtract*** of numbers

```
using System;class Program{   public static void Main()   {       int Total = 0;       int Subtract= 0;       Calculate(10, 20, out Total, out Subtract);       Console.WriteLine("Sum={0} &&Subtract={1}",Total,Subtract);       Console.ReadKey();   }   
   public static void Calculate(int FN,int SN,out int Sum,out int Subtract)   {       Sum = FN + SN;       Subtract= FN - SN;   }}
```

\
**OUTPUT:**![use of out parameter in c#](https://www.mindstick.com/mindstickforums/f0e52ee5-262e-4ccd-9bb4-d283b124f10e/images/312658f1-08ce-4f32-bd7e-2a3ae523ffb9.png)**\****\****I hope you are understand this.**


---

Original Source: https://www.mindstick.com/forum/34334/use-of-out-parameter-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
