C# Objects lecture in color contents of csharp2.txt:

C# Objects

C# Objects

Encapsulation

Traditional

public class Employee
{
       private int empID;
.......
       //Accessor.
       public int GetTheID(){ return empID; }
       //Mutator.
       public void SetTheID(int n)
       {
               // check if  leagal
               empID = n;
       }
}

C# version

public class Employee
{
       private int empID;
.......
       public int EmpID
       {
       //Accessor.
               get { return empId; }
       //Mutator.
               set
               {
               // check if  leagal
               empID = value;
               }
       }       
}

namespace Employees
{
       // Employee is the base class in this hierarchy.
       // It serves to hold data & functionality 
       // common to all employee types.
       abstract public class Employee

c#'s Inheritance and Polymorhism Support


lecture in color

/comp/194NET/notes/csharp2.php3
downloaded on Nov-07-2009 09:59:26 PM,
was last modified on Feb-17-2004 11:34:24 PM.

All lecture note content is copyright 2004 by the Tufts .NET Study Group