C # object-oriented method summary

Source: Internet
Author: User

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
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.