The following code is a very visual understanding of the ASP interface. You can understand the comments in the code.
- PublicPartialClassFx_jk: System. Web. UI. Page
- {
- /* My Understanding of ASP Interfaces
- * I checked a lot of information about the interface and understood it carefully.
- * An interface is actually equivalent to a standard. Every method, attribute, and other objects in the interface,
- * You must implement one by one in the classes that reference it )!
- * There are no specific implementation methods, because interfaces are only the definitions of types and results.
- * It is very useful in team development, especially in a large project.
- *
- * Simply put, you can use interfaces to standardize the source code of a project.
- *
- * Note: The interface definition is an abstract definition, and keywords such as public private are not required.
- * However, these keywords must be used to describe the implemented classes.
- */
-
- # Region Interface
- InterfaceCall// The first Interface
- {String GetVoice (StringClasstype );}
-
- InterfaceCry// Second Interface
- {String GetStrength (IntV );}
-
- // The animal class must implement these two interfaces.
- // The methods in the interface must be implemented according to the method defined in the interface
- ClassAnimal: cry
- {
- // Implement the "get sound" method in the first interface "called"
- Public String GetVoice (StringClasstype)
- {ReturnClasstype ;}
-
- // Implement the "get strength" method in the Second Interface "cry"
- Public String GetStrength (IntV)
- {ReturnV. ToString ();}
- }
-
- # Endregion
-
- Protected VoidLinkbutton#click (ObjectSender, EventArgs e)
- {
- Animal d =NewAnimals ();
-
- Label1.Text = d.GetVoice ("Wang");
- Label1.Text + = d.GetIntensity (80). ToString ();
- }
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.
- C # typical examples and comparisons of interfaces and abstract classes
- What Is A. NET interface? What Is A. NET Abstract class?
- C # interface definition learning experience
- Overview C # COM interface
- C # abstract classes and C # Interfaces