class Program
{
static void Swap(ref int x, ref int y)
{
int temp = x;
x = y;
y = temp;
}
static void Swap(int x, int y)
{
int temp = x;
x = y;
y = temp;
}
static void Main(string[] args)
{
int i = 1, j = 2;
Swap(i, j);
Console.WriteLine("i={0},j={1}", i, j);
Swap(ref i, ref j);
Console.WriteLine("i={0},j={1}", i, j);
Console.Read();
}
}
{
static void Swap(ref int x, ref int y)
{
int temp = x;
x = y;
y = temp;
}
static void Swap(int x, int y)
{
int temp = x;
x = y;
y = temp;
}
static void Main(string[] args)
{
int i = 1, j = 2;
Swap(i, j);
Console.WriteLine("i={0},j={1}", i, j);
Swap(ref i, ref j);
Console.WriteLine("i={0},j={1}", i, j);
Console.Read();
}
}