Skip to content

Value Type Inheritance

Question

Does a value type support inheritance?

Short interview answer

No. A struct cannot inherit from another class or struct and cannot be a base class. It can implement interfaces.

Detailed answer

All value types derive from System.ValueType in the type system, but user-defined structs are implicitly sealed:

public readonly record struct Point(int X, int Y); // Valid value type.
// public struct ColoredPoint : Point { } // invalid: a struct cannot derive from Point.

This prevents a struct inheritance hierarchy. When a value type needs to satisfy shared behavior, define and implement an interface instead.

Sources