
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Value parameters vs Reference parameters vs Output Parameters in C#
Value parameters
The value parameters copy the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.
This is the default mechanism for passing parameters to a method. In this mechanism, when a method is called, a new storage location is created for each value parameter.
The values of the actual parameters are copied into them. Hence, the changes made to the parameter inside the method have no effect on the argument.
Reference Parameters
A reference parameter is a reference to a memory location of a variable. When you pass parameters by reference, unlike value parameters, a new storage location is not created for these parameters. The reference parameters represent the same memory location as the actual parameters that are supplied to the method.
You can declare the reference parameters using the ref keyword.
Output Parameters
A return statement can be used for returning only one value from a function. However, using output parameters, 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.
You can declare the output parameters using the out keyword.
- Related Articles
- How to use Reference Parameters in C++?
- How to pass reference parameters PHP?
- What is the difference between pass by value and reference parameters in C#?
- How do I write a function with output parameters (call by reference) in Python?
- Method Parameters in C#
- How do we pass parameters by reference in a C# method?
- What are default-parameters for function parameters in JavaScript?
- Bond Parameters
- What is “Parameters without defaults after default parameters in JavaScript”
- How are parameters passed in C#?
- What are named parameters in C#?
- PHP Context Parameters
- JavaScript Function Parameters
- Parameters & Arguments in JavaScript.
- Decibel Based Representation of Wireless Communication Parameters - Converting Between the Parameters
