-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaceOverloads.cs
More file actions
40 lines (35 loc) · 956 Bytes
/
Copy pathInterfaceOverloads.cs
File metadata and controls
40 lines (35 loc) · 956 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
37
38
39
40
using System;
public interface IInterface
{
void InterfaceMethod(int x);
void InterfaceMethod(long x);
int InterfaceProperty { get; set; }
}
public class CustomType1 : IInterface
{
public void InterfaceMethod(int x)
{
Console.WriteLine("CustomType1.InterfaceMethod1({0})", x);
}
public void InterfaceMethod(long x)
{
Console.WriteLine("CustomType1.InterfaceMethod2({0})", x);
}
public int InterfaceProperty { get; set; }
}
public static class Program
{
public static void Main(string[] args)
{
var a = new CustomType1();
a.InterfaceMethod(32);
IInterface b = a;
b.InterfaceMethod(32);
a.InterfaceProperty = 16;
Console.WriteLine(a.InterfaceProperty);
Console.WriteLine(b.InterfaceProperty);
b.InterfaceProperty = 17;
Console.WriteLine(a.InterfaceProperty);
Console.WriteLine(b.InterfaceProperty);
}
}