34
1
using System;
2
3
public class Maths {
4
5
public static void Swap(ref int a, ref int b) {
6
int temp = a;
7
a = b;
8
b = temp;
9
}
10
11
public static void Swap(ref string a, ref string b) {
12
string temp = a;
13
a = b;
14
b = temp;
15
}
16
}
17
18
public class Program {
19
public static void Main() {
20
int twenty = 20;
21
int thirty = 30;
22
string forty = "forty";
23
string fifty = "fifty";
24
25
Maths.Swap(ref twenty, ref thirty);
26
Console.WriteLine("twenty = {0}", twenty);
27
Console.WriteLine("thirty = {0}", thirty);
28
29
Maths.Swap(ref forty, ref fifty);
30
Console.WriteLine("forty = {0}", forty);
31
Console.WriteLine("fifty = {0}", fifty);
32
33
}
34
}
Cached Result