How are parameters passed in C#? Are they passed by reference or by value?

By default, all parameters are passed by value in C#. Parameters are only passed by reference if you explicitly include an out or ref modifier. However, you need to be aware that when the type of the parameter is a reference type, you're passing a reference rather than an actual object. For more information, see my article on parameter passing and the C# Programmer's Reference.

[Author: Jon Skeet]

Comments

  • Anonymous
    February 03, 2010
    A very concise and to the topic answer, thank you.

  • Anonymous
    August 09, 2013
    In a very simple language u clear every confusion in this topic.. Thanks a lot...