setter and getter method in X++ Programming Language

 

Serial noimportant
1Class Declaration
2setter Method
3getter Method
4Main Method

Class Declaration


class Class1
{
   str Name;
}

setter Method


public void setName(str _Name)
{
    Name = _Name;
}

getter Method


public str getName()
{
    return Name;
}

Example


public static void main(Args _args)
{
        Class1 c1;
        c1 = new Class1(); 
        // 'new' method is inherited from the Object class.
        c1.setName("Rumman Ansari");
        print c1.getName(); 
    
}

Comments