---
title: "What is the difference between ref & out parameters?"  
description: "What is the difference between ref & out parameters?"  
author: "Rajesh Goswami"  
published: 2010-11-09  
updated: 2020-09-14  
canonical: https://www.mindstick.com/interview/217/what-is-the-difference-between-ref-out-parameters  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# What is the difference between ref & out parameters?

When we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect the actual variable. even the variable passed as out parameter is same as ref parameter, but implementation in c# is different,

Arguement passed as ref parameter must be initialized before it is passed to the method. But in case of out parameter it is not necessary. But after a call to a method as out parameter it is necessary to initialize.

When to use out and ref parameter, out parameter is used when we want to return more than one value from a method.

## Answers

### Answer by Amit Singh

When we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect the actual variable. even the variable passed as out parameter is same as ref parameter, but implementation in c# is different,

Arguement passed as ref parameter must be initialized before it is passed to the method. But in case of out parameter it is not necessary. But after a call to a method as out parameter it is necessary to initialize.

When to use out and ref parameter, out parameter is used when we want to return more than one value from a method.


---

Original Source: https://www.mindstick.com/interview/217/what-is-the-difference-between-ref-out-parameters

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
