Information Technology Reference
In-Depth Information
Sealed Classes
In the previous section, you saw that an abstract class must be used as a base class—it cannot
be instantiated as a stand-alone class. The opposite is true of a sealed class.
￿
A sealed class can be used only as a stand-alone class—it cannot be used as a base class.
A sealed class is labeled with the sealed modifier.
￿
For example, the following class is a sealed class. Any attempt to use it as the base class of
another class will produce a compile error.
Keyword
sealed class MyClass
{
...
}
External Methods
An external method is a method that does not have an implementation in the declaration.
Often the implementation is in a language other than C#.
External methods are marked with the extern modifier and do not have an implementa-
tion in the class declaration. The implementation is replaced by a semicolon.
￿
Keyword
public static extern int GetCurrentDirectory(int size, StringBuilder buf);
No implementation
￿
Connecting the declaration with the implementation is implementation-dependent,
but is often done using the DLLImport attribute. Attributes are covered in detail in
Chapter 21.
Search WWH ::




Custom Search