---
title: "Types of parameter in C#"  
description: "In this Article i am going to show  how many types of parameter we use in method."  
author: "Niraj Kumar Mishra"  
published: 2017-08-25  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/12553/types-of-parameter-in-c-sharp  
category: "c#"  
tags: ["c#", "oops"]  
reading_time: 2 minutes  

---

# Types of parameter in C#

There are 4 different types of [parameters](https://www.mindstick.com/articles/87/passing-parameters-in-c-sharp) a method can have.1. Value parameters: Creates a copy of the [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) passed, so modifications does not affect each other.

##### Example:

```
using System;class Program{    public static void Main()    {        int i = 0;        SimpleMethod(i);        Console.WriteLine(i);        Console.ReadKey();    }    public static void SimpleMethod(int j)    {        j = 101;    }}
```

**[OUTPUT](https://www.mindstick.com/interview/34427/explain-the-output-in-angular):**![Types of parameter in C#](https://www.mindstick.com/mindstickarticle/7467d92d-ccb4-44e2-9651-865acac44b1f/images/e1fc25c9-01cc-4c6a-bb25-1a09d778dfc5.png)**\****2. Reference Parameters:** The ref method parameter keyword on a method parameter causes A method to refer to the same variable that was passed into the method. Any changes made to the parameter in the method will be reflected in that variable when control passed back to the calling method.

##### Example:

```
using System;class Program{   public static void Main()  
   {     int i = 0;     SimpleMethod(ref i);     Console.WriteLine(i);     Console.ReadKey();   }   public static void SimpleMethod(ref int j)   {     j = 101;   }}
```

**OUTPUT:****\**![Types of parameter in C#](https://www.mindstick.com/mindstickarticle/7467d92d-ccb4-44e2-9651-865acac44b1f/images/6cf9024a-c96c-4ad7-bafc-af338dab3552.png)**\****\****3. Out Parameters:**Use when you want a [method to return](https://www.mindstick.com/forum/55125/how-to-create-generic-method-to-return-multiple-list-in-c-sharp) more than one value.**\**

##### Example:

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

##### \

##### OUTPUT:

![Types of parameter in C#](https://www.mindstick.com/mindstickarticle/7467d92d-ccb4-44e2-9651-865acac44b1f/images/e09f793e-ae8b-4d0d-b2e3-2d4cf56bf274.png) \

\

4. Parameter Arrays: the params keyword lets you specify a method parameter that takes a variable number of arguments. You can send a comma-separated list of arguments, or only one params keyword is permitted in a method declaration.

##### Example:

```
using System;class Program{   
 public static void Main() {      
   int[] Numbers = new int[3];   Numbers[0] = 101;   Numbers[1] = 102;   Numbers[2] = 103;   ParamsMethod();   //ParamsMethod(Numbers);    
   //ParamsMethod(1, 2,3, 4, 5); 
 }   
 public static void ParamsMethod(params int[] Numbers) {      
  Console.WriteLine("There are {0} elements",Numbers.Length);  foreach (int i in Numbers)   {     Console.WriteLine(i);   }     Console.ReadKey(); }}
```

\

##### OUTPUT:

##### ![Types of parameter in C#](https://www.mindstick.com/mindstickarticle/7467d92d-ccb4-44e2-9651-865acac44b1f/images/f7776a37-3ffa-4f4d-944a-1542d992a634.png)

##### If you use ParamsMethod(Numbers); method then output are:

##### \
![Types of parameter in C#](https://www.mindstick.com/mindstickarticle/7467d92d-ccb4-44e2-9651-865acac44b1f/images/7528fa7f-2864-4212-a91d-06e5a0991d3f.png)

##### and again if you are use ParamsMethod( ); method then outpur are:

##### \
![Types of parameter in C#](https://www.mindstick.com/mindstickarticle/7467d92d-ccb4-44e2-9651-865acac44b1f/images/a16a777d-0cb6-4564-b6f7-e57e7bd01767.png)

## \

---

Original Source: https://www.mindstick.com/articles/12553/types-of-parameter-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
