-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathProgram.cs
38 lines (33 loc) · 899 Bytes
/
Program.cs
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
using Library;
namespace Virtuals
{
class Program
{
static void Main()
{
var d = new CustomerDerived();
LibraryBase b = d;
d.Start();
b.Start();
}
public static void CallVirtualMethod(BaseWithVirtual o)
{
o.ShowMessage();
}
public static void ExploitingVirtualMethods()
{
CallVirtualMethod(new BaseWithVirtual());
CallVirtualMethod(new DeriveWithoutOverride());
CallVirtualMethod(new DeriveAndOverride());
}
}
// For illustration only - this type is define by .NET so we don't
// need to define it ourselves. The book just shows it as an example.
#if false
public interface ISet<T> : ICollection<T>
{
new bool Add(T item);
// ... other members omitted for clarity
}
#endif
}