Passing by reference C# with Example
If you want the Value Types vs Reference Types in methods example to work properly, use the ref keyword in your method signature for the parameter you want to pass by reference, as well as when you call the method. public static void Main(string[] args) { ... DoubleNumber(ref number); // calling code Console.WriteLine(number); // outputs 8 ... } public void DoubleNumber(ref int number) { number += number; } Making these changes would make the number update as expected, meaning the console output for number would be 8.