User Shared variable to count instance number : Shared « Class « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
VB.Net » Class » SharedScreenshots 
User Shared variable to count instance number
User Shared variable to count instance number

Imports System.IO

Module Module1

    Sub Main()
        Dim As New Professor()
        Console.WriteLine("count {0}", p.Count)

        Dim pp As New Professor()
        Console.WriteLine("count {0}", pp.Count)

    End Sub

End Module

    Class Professor
        Public Shared Count As Integer = 0

        Public Name As String
        Private Age As Integer
        Public OfficeNumber As String
        Private HomePhone As String

        Public Sub New()
            Count = Count + 1
        End Sub
        

    End Class

           
       
Related examples in the same category
1. Shared Method DemoShared Method Demo
2. Use Shared method to construct ObjectUse Shared method to construct Object
3. Class with all shared Member variablesClass with all shared Member variables
4. Class Shared VariableClass Shared Variable
w___w__w.__ja__v__a__2_s._c__o__m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.