Saturday, 25 May 2013

C# Simple Program to Pass Value as Reference


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace paravalue

{

    class Program

    {

        static void Main(string[] args)

        {

            int a = 10, b = 20;//actual var

            Console.WriteLine("A=" + a + " B=" + b);

            swap(a, b);

            Console.WriteLine("A=" + a + " B=" + b);

        }

 

        private static void swap(int x, int y) //formal var

        {

            int z;

            z=x;

            x = y;

            y = z;

            Console.WriteLine("X=" + x + " Y=" +y );

 

        }

    }

}

 

No comments:

Post a Comment