can any one help me!

hi
can any one tell me the usage of "shared constructor"in vb.net .i would be glad if any one send me an example about that !
thank u

Comments

  • : hi
    : can any one tell me the usage of "shared constructor"in vb.net .i would be glad if any one send me an example about that !
    : thank u
    :
    :

    A shared constructor executes before the constructor of the first object instance. The shared constructor is private so there is no special way to instantiate an object with a shared constructor. Shared constructors can also initialize only shared properties and is the only place you can initialize Shared ReadOnly properties.


    Class SomeClass

    Shared ReadOnly GlobalID As Integer

    ' The shared constructor executes only once for all object instances
    Shared Sub New()
    GlobalID = 12345
    End Sub

    ' Regular Constructor
    Sub New()
    ' Cant initialize shared properties here
    End Sub

    End Class
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion