Chapter 11. Shared Members


Visual Basic .NET Unleashed
By Paul Kimmel
Table of Contents
Part II.  Advanced Object-Oriented Programming

Chapter 11. Shared Members

In This Chapter

  • Declaring Shared Fields

  • Defining Shared Properties

  • Using Shared Methods

  • Defining Shared Constructors

  • Implementing Factory Methods

  • Overloading Shared Members

  • Raising Shared Events

  • Summary

Shared members in Visual Basic .NET are equivalent to Object Pascal class members and C++ and Java static members. The term member refers to anything that is part of a class or structure, which includes fields, properties, methods, and events. The designator Shared means that you can access the member without creating an instanceor declaring a variableof the class or structure. Using the Shared designation means that the member is a metaclass member; that is, shared members are accessible from the class (and from objects).

Until Visual Basic .NET, shared members haven't been supported in Visual Basic. In this chapter, you will discover that there are many shared members in existing Visual Basic .NET code and the CLR, and that you can implement some advanced idioms using shared members. Chapter 11 demonstrates how to declare and use shared fields, properties, methods, constructors, overloaded members, and events. In addition to explaining shared members, Chapter 11 will demonstrate idioms, such as how to implement factory methods.


Visual BasicR. NET Unleashed
Visual BasicR. NET Unleashed
Year: 2001
Pages: 222 © 2008-2017.
If you may any questions please contact us: