using System;
public class exam
{
public static void swap(ref int a,ref int b)
{
int t;
t = a;
a = b;
b = t;
Console.WriteLine("\nA value is : {0}",a);
Console.WriteLine("\nB value is : {0}",b);
}
public static void Main()
{
int x,y;
Console.Write("\nEnter the A value : ");
x = int.Parse(Console.ReadLine());
Console.Write("\nEnter the B value : ");
y = int.Parse(Console.ReadLine());
Console.WriteLine("\n");
Console.WriteLine("The Given values are...");
Console.WriteLine("\nA value is : {0}",x);
Console.WriteLine("\nB value is : {0}",y);
Console.WriteLine("\n");
Console.WriteLine("After the Swap, the values are...");
swap(ref x,ref y);
}
}C#
Method - call by reference

Written by
View ProfileSenthilvelan Sambamoorthy
Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.
