IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
VB.Net
Search VB.Net Group:

Advanced
-Collapse +Expand VB.Net To/From
To/FromCODEGuides
-Collapse +Expand VB.Net Store
PRESTWOODSTORE

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingVB.NetOOP   Print This     
  From the May 2009 Issue of Prestwood eMag
 
VB.Net OOP:
VB.Net Shared Members (Shared)
 
Posted 16 years ago on 10/31/2008 and updated 1/19/2009
VB.Net Code Snippet:
 A flashcard from our VB.Net Flashcards Library
 A code snippet from our VB.Net Code Snippets Page

KB101484

General Info: Static Class / Static Member

A static member is a member you can have access to without instantiating the class into an object. For example, you can read and write static properties and call static methods without ever creating the class. Static members are also called class members (class methods, class properties, etc.) since they belong to the class and not to a specific object. A static class is a class that contains only static members. In the UML, these classes are described as utility classes.

Languages Focus: Static Member

Languages that support static members usually at least support static member fields (the data). Some languages also support static methods, properties, etc. in which case the class member is held in memory at one location and shared with all objects. Finally, some languages support static classes which usually means the compiler will make sure a static class contains only static members.

VB.Net Shared Members

VB.Net supports both static members and static classes (use the keyword Shared). You can add a static method, field, property, or event to an existing class.

You can designate a class as static and the compiler will ensure all methods in that class are static. You can add a constructor to a static class to initialize values.

The CLR automatically loads static classes with the program or namespace.

Syntax Example:
Public Shared Function MySharedFunction() As Integer
  MySharedFunction = 12345
End Function

More Info

Definition:  Static Class / Static Member

Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1105A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains play-drums.com and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile


Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

Advanced

1 Advanced Level Question

Question #1: Multiple Choice

Which answer best describes VB.Net's support for static members and clsasses?

Answer:
1. 

VB.Net supports both static members and static classes (use the keyword Static). You can add a static method, field, property, or event to an existing class.

2. 

VB.Net supports static members only (use the keyword Shared).

3. 

VB.Net supports both static members and static classes (use the keyword Shared). You can add a static method, field, property, or event to an existing class.

4. 

VB.Net supports static classes only (use the keyword Static).

5. 

None of the above. VB.Net does not support static classes nor members.


 KB Article #101484 Counter
12061
Since 10/31/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]