Difference between Variables & Properties

Variables

Properties

Variable is named location in memory in which a value is store

Property represents information that an Object contains.

Can Declared anywhere in the Program

Should be implemented with ‘Property’ Procedure

No ‘GET – SET’ Sections are present, it declared simply using Access Specifier and the Data Type of the Variable

Properties are implemented with ‘GET – SET’ Sections that are used to Retrieve & Set the Data

Syntax:

As

Syntax:

Property As

Get

//statements

End Get

Set(ByVal value As )

//statements

End Set

End Property

Example:

o Dim num As Integer

o Public _name As String

Example:

Public Property name () As String

Get

Return _name

End Get

Set (ByVal value As String)

_name=value

End Set

End Property

Regards,
Mayur Dighe
http://ImmortalDotNet.blogspot.com
http://MayurDighe.wordpress.com