Conclusion

 <  Day Day Up  >  

Whereas inheritance is a powerful way of using the relationships between related types to reuse code, interfaces are powerful a way of using commonalities between unrelated types to reuse code. Interfaces are useful to express generalized capabilities that any type can have, and they are used extensively in the .NET Framework for this purpose. Now that we have covered all the major types in the Framework, the next chapter starts a discussion of advanced language topics. First up is a discussion of attributes, which allow programmers to attach user -defined information to types in an assembly.

Here are some style points to consider.

  • By convention, all interface names start with the uppercase letter I .

  • Because it can be confusing to consumers of the type to have two names for the same method, it is generally best to use the same names when you are implementing an interface.

  • Because COM classes do not always declare every interface that they support, it is valid to convert a class to an interface that it does not explicitly implement, and vice versa. If the class is a COM class, this turns into a runtime QueryInterface call for the particular interface. If the class is not a COM class, the conversion will fail at runtime.

 <  Day Day Up  >  


The Visual Basic .NET Programming Language
The Visual Basic .NET Programming Language
ISBN: 0321169514
EAN: 2147483647
Year: 2004
Pages: 173
Authors: Paul Vick

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net