[Previous] [Contents] [Next]

Defining Classes


The syntax used for defining classes in C# is simple, especially if you usually program in C++ or Java. You place the class keyword in front of the name of your class and then insert the class's members between the "curlies," like so: -

class Employee
{
    private long employeeId;
}

As you can see, this class is as basic as it gets. We have a class named Employee that contains a single member named employeeId. Notice the keyword private that precedes our member. This is called an access modifier. Four valid access modifiers are defined by C#, and I'll cover them in a moment.

[Previous] [Contents] [Next]