Understanding of ASP interface: animal type example

Source: Internet
Author: User
Tags abstract definition

The following code is a very visual understanding of the ASP interface. You can understand the comments in the code.

 
 
  1. PublicPartialClassFx_jk: System. Web. UI. Page
  2. {
  3. /* My Understanding of ASP Interfaces 
  4. * I checked a lot of information about the interface and understood it carefully. 
  5. * An interface is actually equivalent to a standard. Every method, attribute, and other objects in the interface, 
  6. * You must implement one by one in the classes that reference it )! 
  7. * There are no specific implementation methods, because interfaces are only the definitions of types and results. 
  8. * It is very useful in team development, especially in a large project. 
  9. * Simply put, you can use interfaces to standardize the source code of a project. 
  10. * Note: The interface definition is an abstract definition, and keywords such as public private are not required. 
  11. * However, these keywords must be used to describe the implemented classes. 
  12. */ 
  13.  
  14. # Region Interface 
  15. InterfaceCall// The first Interface 
  16. {String GetVoice (StringClasstype );}
  17.  
  18. InterfaceCry// Second Interface 
  19. {String GetStrength (IntV );}
  20.  
  21. // The animal class must implement these two interfaces. 
  22. // The methods in the interface must be implemented according to the method defined in the interface 
  23. ClassAnimal: cry
  24. {
  25. // Implement the "get sound" method in the first interface "called" 
  26. Public String GetVoice (StringClasstype)
  27. {ReturnClasstype ;}
  28.  
  29. // Implement the "get strength" method in the Second Interface "cry" 
  30. Public String GetStrength (IntV)
  31. {ReturnV. ToString ();}
  32.  
  33. # Endregion 
  34.  
  35. Protected VoidLinkbutton#click (ObjectSender, EventArgs e)
  36. {
  37. Animal d =NewAnimals ();
  38.  
  39. Label1.Text = d.GetVoice ("Wang");
  40. Label1.Text + = d.GetIntensity (80). ToString ();
  41. }

After reading the above examples, I hope to enhance the reader's understanding of ASP interfaces.

The code in this article comes from the blog of the Free programmer: the meaning of interfaces.

  1. C # typical examples and comparisons of interfaces and abstract classes
  2. What Is A. NET interface? What Is A. NET Abstract class?
  3. C # interface definition learning experience
  4. Overview C # COM interface
  5. C # abstract classes and C # Interfaces

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.