An interface can be regarded as a "pure" abstract class, and all its methods are abstract methods.
Two interface implementation methods: Implicit interface implementation and explicit interface implementation
There are two main forms of polymorphism programming:
(1) Inheritance polymorphism:
(2) interface polymorphism:
Delegate: it is an important extension of. NET Framework for object-oriented programming language features such as C # and VB. NET. Delegation is an important technology in. NET, such as the technical basis for events, asynchronous calls, and multi-thread development. Delegation is widely used in. NET development. Every. NET software engineer must understand the delegation.
View Code
1 // Declare delegate -- defines required signature:
2 delegate double MathAction (double num );
3
4 class DelegateTest
5 {
6 // Regular method that matches signature:
7 static double Double (double input)
8 {
9 return input * 2;
10}
11
12 static void Main ()
13 {
14 // Instantiate delegate with named method:
15 MathAction ma = Double;
16
17 // Invoke delegate ma:
18 double multByTwo = ma (0, 4.5 );
19 Console. WriteLine (multByTwo );
20
21 // Instantiate delegate with anonymous method:
22 MathAction ma2 = delegate (double input)
23 {
24 return input * input;
25 };
26
27 double square = ma2 (5 );
28 Console. WriteLine (square );
29
30 // Instantiate delegate with lambda expression
31 MathAction ma3 = s => s * s;
32 double cube = ma3 (4.375 );
33
34 Console. WriteLine (cube );
35}
36}
From sc1230