Appendix K : Classes and Structures


This appendix provides information about class and structure declarations.

Classes

The syntax for declaring a class is:

  [attribute_list] [Partial] [accessibility] [Shadows] [inheritance] _  Class name[(Of type_list)]     [Inherits parent_class]     [Implements interface]     statements End Class

The attribute_list can include any number of attribute specifiers separated by commas.

The accessibility clause can take one of the values: Public, Protected, Friend, Protected Friend, and Private.

The Partial keyword indicates that this is only part of the class declaration and that the program may include other partial declarations for this class.

The Shadows keyword indicates that the class hides the definition of some other entity in the enclosing class’s base class.

The inheritance clause can take the value MustInherit or NotInheritable.

The type_list clause defines type parameters for a generic class. For information on generics, see Chapter 19.

The Inherits statement tells which class this class inherits from. A class can include at most one Inherits statement and, if present, this must be the first non-comment statement after the Class statement.

The Implements statement specifies an interface that the class implements. A class can implement any number of interfaces. You can specify interfaces in separate Interface statements or in a single statement separated by commas.

The following example declares a simple Person class and an Employee class that inherits from it:

  Public Class Person End Class Public Class Employee     Inherits Person End Class 




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

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