emp.SocialSecurityNumber = "222-22-2222";
Console.ReadLine();
} Static Properties
C# also supports static properties. Recall from earlier in this chapter that static members are
accessed at the class level, not from an instance (object) of that class. For example, assume that the
Employee type defines a static point of data to represent the name of the organization employing
these workers. You may encapsulate a static property as follows:
class Employee
{
...
C H A P T E R 5
D E F I N I N G E N C A P S U L AT E D C L A S S T Y P E S
8849CH05.qxd 10/22/07 1:34 PM Page 171
get { return companyName; }
}
Static properties are manipulated in the same manner as static methods, as shown here: