Passing value by reference method in C#


Passing value by a reference method in C#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MYPROJECT.startup
{


        class startupday1

        {

            static void Main()

            {

            int y = 0;
            
            func(ref y);

                Console.Write("new value is {0}\n", y);

                Console.Write("new value is {0}\n", func(ref y));
                Console.ReadKey();
             }
             static int func(ref int x)

            {
              x = 10;
              return x;
}

 }

 }
                 OUTPUT




Comments

Popular posts from this blog

Input and output in C#

Printing Hello World in C#

Passing value without reference in C#