You need to sign in to do that
Don't have an account?

Set and Get Method Explination
Hi..
Please Explain About Set And get Methods IN simple way..
"Get" and "Set" Methods How thes work ::
1- Visual Force -To- Class(console).
2-Console(Class) -To- VisualForce
Please Explain About Set And get Methods IN simple way..
"Get" and "Set" Methods How thes work ::
1- Visual Force -To- Class(console).
2-Console(Class) -To- VisualForce
get and set both are methods associated with every variable in oops concept .
get means you can read the value in your variable and set means you can write or update the variable value.
This enhance the security of your data inside the class.
Suppose if you want to make a variable readonly then you can do like this public string var{get;} , Now whenever any user will try to
write something in this variable it will throw error. this read only property can be use in scenario like if you want to show the data to the user but want to restrict the user that he can't write anything then in that case you can use this readonly property.
set() method is used to accept some value in a variable , suppose there is a form displaying on screen then user input something and you can accept that inside the variable whose set property is enable.. you can make a variable write only with help of this . public string var {set;} now this variable can be use to receive input but can't use to show the data or display the data to the user.
or you can make a variable read/write in this way public string var {get;set} now thios variable can be use in read as well as write operation.
Thanks
Rishav'
You may like to see this examples here:
http://www.cloudforce4u.com/2013/07/pass-parameter-to-visualforce-page.html
http://www.cloudforce4u.com/2013/07/pass-value-from-visualforce-page-to.html