Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27350

Classes: What are Private properties for?

$
0
0
I'm not sure if I'm using the correct terminology. But say I have the following class:

Code:

Public Class clProject

    'Constructors
    Public Sub New()
        MyBase.New()
    End Sub

    'Private Fields/Properties
    Private _ID As Integer
    Private _ClientID As Integer

    'Properties
    Public Property ID As Integer
        Get
            Return _ID
        End Get
        Set(ByVal value As Integer)
            _ID = value
        End Set
    End Property

    Public Property ClientID As Integer
        Get
            Return _ClientID
        End Get
        Set(ByVal value As Integer)
            _ClientID = value
        End Set
    End Property
End Class

I'm talking about the _ID and _ClientID. I just don't understand their purpose. Like when would a public property's value be different from its private counterpart? Someone please help me understand. Thanks.

Viewing all articles
Browse latest Browse all 27350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>