Results 1 to 3 of 3

Thread: What is the technical and practical difference bettween these two:

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    What is the technical and practical difference bettween these two:

    I guess the first one is not professional, but I want to know the exact technical and practical difference between these two class definisions:

    First:
    Public Class myClass

    Public Shared myString as String

    End Class


    Second:
    Public Class myClass

    Private Shared c_myString
    Public Shared Property myString() As String
    Get
    Return c_myString
    End Get
    Set(ByVal Value As String)
    c_myString = Value
    End Set
    End Property

    End Class


    Thanx

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    The first one uses a field and the other uses a property. As far as technical difference there isn't a whole lot in this example, but practical there is. You have more control over a property, that is the general answer. I think most developers find it good habit to use properties most of the time.

    With a field you have no control over the variables access or validation, creation, or whatnot. It gets even more complex when the property is another class.

  3. #3
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872
    if you use properties while making an usercontrol or so, you have the properties in the property window if you ad your control to an application. You can add inputcontrol to your "Set property".
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width