C# class
In this chapter you will learn:
Description
Classes are essentially templates from which you can create objects.
A class is the most common kind of reference type.
Syntax
The simplest possible class declaration is as follows:
class YourClassName
{
}
The general syntax to declare a class is
[public, /* ww w .ja v a 2s . com*/
internal,
abstract,
sealed,
static,
unsafe,
partial] class YourClassName [ Generic type parameters, a base class, and interfaces]{
methods,
properties,
indexers,
events,
fields,
constructors,
operator functions,
nested types,
a finalizer
}
Example
In the following code we define a class named Person.
class Person
{
}
Next chapter...
What you will learn in the next chapter:
- What are C# Nested Types
- Example for Nested Types
- Note for Nested Types
- Accessing a private member of a type from a nested type
- Applying the protected access modifier to a nested type
- Referring to a nested type from outside the enclosing type