Answers for "c# pass value by reference"

C#
2

c# pass value by reference

using System;

namespace ProgramName
{
     class Program
     {
         static void Main(string[] args)
         {
             int x = 10;
             Console.WriteLine("Variable Value Before Calling the Method: {0}", x);//10
             Square(ref x);
             Console.WriteLine("Variable Value After Calling the Method: {0}", x);//100
         }
         public static void Square(ref int a)
         {
              a *= a;
              Console.WriteLine("Variable Value Inside the Method: {0}", a);//100
         }
     }
}
Posted by: Guest on June-25-2021

Code answers related to "c# pass value by reference"

C# Answers by Framework

Browse Popular Code Answers by Language