O'Reilly logo

C# 5.0 Programmer's Reference by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix K Classes and Structures

This appendix provides information about class and structure declarations.

Classes

The syntax for declaring a class follows.

«attributes» «accessibility» «abstract|sealed|static» «partial»
    class name «inheritance»
{
    statements
}

The following list describes the declaration’s pieces.

  • attributes—This can include any number of attribute specifiers.
  • accessibility—This can be one of public, internal, private, protected, or protected internal.
  • abstract—This keyword means you cannot create instances of the class. Instead you can make instances of derived classes.
  • sealed—This keyword means you cannot derive other classes from the class.
  • static—This keyword means you cannot derive other classes from the class or create instances of it. You invoke the members of a static class by using the class’s name instead of an instance. All members of a static class must also be declared static.
  • partial—This keyword indicates that this is only part of the class declaration and that the program may include other partial declarations for this class.
  • name—This is the name you want to give the class.
  • inheritance—This clause can include a parent class, one or more interfaces, or both a parent class and interfaces. If the declaration includes a parent class and interfaces, the parent class must come first.

Structures

The syntax for writing a structure follows.

«attributes» «accessibility» «partial» struct name «interfaces»
{
    statements
}

The structure’s attributes

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required