Once you create an instance of a reference type using the new
keyword, you can interact with the new object through the variable that
serves as a reference to that object. You can call the object’s
methods or read and write its properties.
14
| // Make a new Person objectPerson p1 = new Person("Sean", 46);// Read some propertiesstring theName = p1.Name; // Seanint howOld = p1.Age; // 46// Set Age property to new valuep1.Age = p1.Age - 10;int younger = p1.Age; // Now 36// Call method that takes no parameters, returns description// Will return: Sean is 36 yrs old.string describe = p1.Description(); |
Sign up here with your email
ConversionConversion EmoticonEmoticon