Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HEllo experts,

This is the dumbest question I ever asked.
I don't understand this get and set in the function.
Could some one help in making me understand the function?
XML
<Serializable()> _
Public Class FilterRebates
  Private sName As StringPublic Property Name() As String
   Get
     Return sName
   End Get
   Set(ByVal value As String)
     sName = value
   End Set
 End Property
End Class
Posted
Comments
Sergey Alexandrovich Kryukov 19-Jun-15 12:04pm    
Well, and what's wrong with reading original MSDN documentation? Anyway, I explained the idea in Solution 2.
—SA

You simply need to understand what a property is. The idea behind the property is: the possibility to mimic the functionality of the field as it is seen from the side of the user's code: reading the value and assignment of the value.

But unlike the field, the property introduces additional features only seen on the side of the declaring type: the possibility to implement side effect for both operations depending on the data and the declaring type internals: getter method called at "reading" of the property value and setter method called at "assignment". Additionally, it's the possibility to implement read-only or write-only semantic.

Please see: https://msdn.microsoft.com/en-us/library/bc3dtbky.aspx[^].

Therefore, you should understand your get and set sections in your VB.NET code as the syntax use to implement getter and setter methods. You can use reflection or disassemble the code and see that, from the standpoint of the CIL code, they are real methods associated with the property.

—SA
 
Share this answer
 
Comments
sudevsu 19-Jun-15 12:44pm    
Thank you
Sergey Alexandrovich Kryukov 19-Jun-15 14:06pm    
You are welcome.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900