Data members are members that contain the data of the class - fields, constants, and events. Details members can be static (associated with the class as a whole) or the instance (each instance of the class has its own copy of the data). As usual for object - oriented languages to a class member is always a
instance member unless explicitly declared as static.
Once you have an instance of an object PhoneCustomer can access these fields using the Object.FieldName syntax, as shown in this example:
PhoneCustomer Customer1 = new PhoneCustomer();
Customer1.FirstName = “Simon”;
Constants may be associated with the classes in the same way as variables. You declare a constant with const keyword. Again, if declared as public, will be accessible from outside the class.
class PhoneCustomer
{
public const string DayOfSendingBill = “Monday”;
public int CustomerID;
public string FirstName;
public string LastName;
}
0 comments:
Post a Comment