I am reading the .NET documentation, and encountered the IdentityReference
class, which states:
Represents an identity and is the base class for the NTAccount and SecurityIdentifier classes. This class does not provide a public constructor, and therefore cannot be inherited.
My confusion is that it says it cannot be inherited, yet it also states it is the base class for the NTAccount
and SecurityIdentifier
classes. Based on my understanding, these classes are inheriting IdentityReference
.
Is the documentation incorrect, or is my understanding incomplete? Should the documentation say 'This class does not provide a public constructor, and therefore cannot be instantiated'?
The documentation is correct. A child class must be able to call a base class constructor, whether the default parameterless constructor or another one. The IdentityReference
class has no public or protected constructor though. If you try to inherit from it, you'll get a compilation error.
The class has an internal constructor, which allows classes in its own assembly to inherit from it
public abstract class IdentityReference
{
internal IdentityReference()
{
// exists to prevent creation user-derived classes (for now)
}
NTAccount is defined in the same assembly so it can inherit from IdentityReference
:
public sealed class NTAccount : IdentityReference
{
...
The class is sealed
though so other assemblies can't inherit from it either