Skip to main content

Notifications

Announcements

No record found.

Accessor Methods

Accessor methods enable other elements to set or get the values of variables in a
class and it is common that they do both.
The following example accepts a value as a parameter, sets a class variable to
this value and then returns the value. The parameter has a default value set to the
class variable value, so if the method is called without a parameter, it returns the
value of the class variable. If it is called with a value in the parameter, then the
class variable is set to this value.


1
2
3
4
5
public str myName(str _myName = myName)
{
myName = _myName;
return myName;
}

Best Regards,
Hossein Karimi

Comments

*This post is locked for comments