tailieunhanh - Lesson13: Interfaces

An interface looks like a class, but has no implementation. The only thing it contains are definitions of events, indexers, methods and/or properties. The reason interfaces only provide definitions is because they are inherited by classes and structs, which must provide an implementation for each interface member defined. | Tutorial Page 1 of 3 Using Excellent Tools to Write Web Applications Tar the .NET Common Language Runtime CLR Home Up Lesson01 Lesson02 Lesson03 Lesson04 Les Lesson06 Lesson07 Lesson08 Lesson09 Lesson10 Les Lesson12 Lesson13 On sale Now C Unleashed is an indepth guide for intermediate to advanced software developers to learn the C programming language and serve as a desktop reference. The C Station Tutorial by Joe Mayo 02 24 02 Lesson 13 Interfaces This lesson teaches C Interfaces. Our objectives are as follows Understand the Purpose of Interfaces. Define an Interface. Use an Interface. Implement Interface Inheritance. An interface looks like a class but has no implementation. The only thin it contains are definitions of events indexers methods and or properties. The reason interfaces only provide definitions is because the are inherited by classes and structs which must provide an implementation for each interface member defined. So what are interfaces good for if they don t implement functionality They re great for putting together plug-n-play like architectures where components can be interchanged at will. Since all interchangeable components implement the same interface they can be used without an extra programming. The interface forces each component to expose specific public members that will be used in a certain way. Because interfaces must be defined by inheriting classes and structs the define a contract. For instance if class foo inherits from the Disposable interface it s making a statement that it guarantees it has the Dispose method which is the only member of the Disposable interface. Any codt that wishes to use class foo may check to see if class foo inherits Disposable. When the answer is true then the code knows that it can call . Listing 13-1 shows how to define an interface Listing 13-1. Defining an Interface interface IMylnterface http Tutorials 6 24 2002 Tutorial Page 2 of 3 void .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.