-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplexRefOverload.cs
More file actions
36 lines (31 loc) · 906 Bytes
/
Copy pathComplexRefOverload.cs
File metadata and controls
36 lines (31 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
public static class Program {
public static bool Method (ref object x, object y, object z) {
Console.WriteLine("Method(<ref object>, <object>, <object>)");
if (x == y) {
x = z;
return true;
} else
return false;
}
public static bool Method (ref int x, int y, int z) {
Console.WriteLine("Method(<ref int>, <int>, <int>)");
if (x == y) {
x = z;
return true;
} else
return false;
}
public static void Main (string[] args) {
int a = 0;
object o = null;
Method(ref o, null, "a");
Console.WriteLine("{0}", o);
Method(ref o, "a", "b");
Console.WriteLine("{0}", o);
Method(ref a, 0, 1);
Console.WriteLine("{0}", a);
Method(ref a, 1, 2);
Console.WriteLine("{0}", a);
}
}