Pass integer by reference : Function Parameters : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Function Parameters »

 

Pass integer by reference








    
 
using System;

public class Starter {

    public static void MethodA(ref int parameter) {
        parameter = parameter + 5;
    }

    public static void Main() {
        int var = 2;
        MethodA(ref var);
        Console.WriteLine(var); // 7
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Function Parameters