Instanciating a shared class.

I have the following class:
Imports System.Web.Security

Public Class MYMembership

Shared Sub New()
End Sub

Public Shared ReadOnly MYMembership() as SqlMembershipProvider
   Get
      Return Membership.Providers("MyMembershipProvider")
   End Get
End Property
End Class

If I want to use this class I have to code MyMembership.MyMembership...(methods and properties)

How can I setup this class so that MyMembership.(methods and properties)

Thanks
DigitalDan3Asked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
You need to create other Shared Properties that access "MYMembership.MYMembership" for you...

I have no idea how to use SqlMembershipProvider, but hopefully this should give you the idea:

    Public Class MYMembership

        Public Shared ReadOnly MYMembership() as SqlMembershipProvider
            Get
                Return Membership.Providers("MyMembershipProvider")
            End Get
        End Property

        Public Shared ReadOnly Property SomeProperty() As String
            Return MYMembership.MYMembership.SomeProperty()
        End Property

    End Class    

Then you can use:

    MYMembership.SomeProperty
0
 
vbturboCommented:
You will need to make an instance to the class from the calling Form or class in order to access the
functionallity which your MYMembership class provide.

See: Shared members are properties, procedures, and fields that are shared by all instances of a class
http://msdn2.microsoft.com/en-us/library/4hbsxy95(VS.71).aspx
And
http://msdn2.microsoft.com/en-us/library/zc2b427x(vs.71).aspx

vbturbo
0
 
DigitalDan3Author Commented:
Heres what I came up with.

Imports System.Web.Security

Public Class MYMembership

Shared Sub New()
End Sub

Public Shared ReadOnly Membership() as SqlMembershipProvider
   Get
      Return System.Web.Security.Membership.Providers("MyMembershipProvider")
   End Get
End Property
End Class
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.