How to Inherit from a Class and Call the Base Constructor in C#
When one kind of thing is a special case of another, like a dog is an animal, a C# class can inherit from another: class Dog : Animal. The dog gets everything the animal has, and its constructor hands the values the animal needs to the animal's constructor with : base(...).
Syntax
class <Derived> : <Base>
{
public <Derived>(<parameters>) : base(<arguments>)
{
<code specific to Derived>
}
}
| Part | What it does |
|---|---|
class <Derived> : <Base> | Declares that <Derived> inherits from <Base>, and gets its members. |
: base(<arguments>) | Calls the base class's constructor with these arguments before the derived constructor's body runs. |
<code specific to Derived> | Whatever the derived class adds. It may be empty. |
Microsoft's inheritance guide: "Inheritance enables you to create new classes that reuse, extend, and modify the behavior defined in other classes. The class whose members are inherited is called the base class, and the class that inherits those members is called the derived class." The base keyword reference lists, among its uses: "Specify which base-class constructor to call when creating instances of the derived class."
The Example
An Animal class stores a name and can describe itself. A Dog class inherits from it, passes its name to Animal's constructor, and adds a Speak method of its own.
Prerequisites
- The .NET 10 SDK or newer, which runs a single
.csfile withdotnet run. This guide uses .NET SDK 10.0.404.
Step 1: Write the Code
Create a file named main.cs in an empty folder:

var dog = new Dog("Rex");
Console.WriteLine(dog.Describe());
Console.WriteLine(dog.Speak());
class Animal
{
public Animal(string name)
{
Name = name;
}
public string Name { get; }
public string Describe() => $"{Name} is an animal.";
}
class Dog : Animal
{
public Dog(string name) : base(name)
{
}
public string Speak() => $"{Name} says woof.";
}
Dog never declares Name or Describe: it inherits both from Animal. Its constructor body is empty because : base(name) already did the work.
Step 2: Run It
dotnet run main.cs
Rex is an animal.
Rex says woof.

Describe came from Animal, Speak from Dog, and both saw the name Rex that : base(name) passed to Animal. The command is the same in zsh, bash and PowerShell.
What Happens Without : base(...)
Leave out the call to the base constructor:
var dog = new Dog("Rex");
Console.WriteLine(dog.Name);
class Animal
{
public Animal(string name)
{
Name = name;
}
public string Name { get; }
}
class Dog : Animal
{
public Dog(string name)
{
}
}
/Users/you/demo/main.cs(16,12): error CS7036: There is no argument given that corresponds to the required parameter 'name' of 'Animal.Animal(string)'
The build failed. Fix the build errors and run again.
Without : base(...), C# tries to call Animal's constructor with no arguments, and there isn't one. Microsoft's constructors guide: "If a base class doesn't offer a parameterless constructor, the derived class must make an explicit call to a base constructor by using base."
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Leaving out : base(...) when the base class has no parameterless constructor | error CS7036: There is no argument given that corresponds to the required parameter 'name' of 'Animal.Animal(string)' | Add : base(name) to the derived constructor |
Expecting new Dog("Rex") to work without a Dog constructor | Constructors aren't inherited, so Dog has no constructor that takes a name | Declare one and pass the name on with base |
| Copying the base class's fields into the derived class | Two copies of the same data | Use the inherited members |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
CS7036 pointing at the derived class's constructor | The base constructor needs arguments that aren't passed | Add : base(<arguments>) |
| A member of the base class isn't visible in the derived class | It's private | Make it protected or public |
FAQ
Are constructors inherited?
No. The inheritance guide: "When you define a class to derive from another class, the derived class implicitly gains all the members of the base class, except for its constructors and finalizers." That's why Dog declares its own constructor.
Can a class inherit from two classes?
No. The guide: "A derived class can have only one direct base class." It can implement any number of interfaces, though.
Conclusion
class Dog : Animal gives Dog everything Animal has, and public Dog(string name) : base(name) passes the constructor's value on to Animal's constructor, which runs first. Without that call, a base class that needs arguments stops the build with CS7036.
Additional Resources
- Inheritance in C#, on Microsoft Learn.
- The base keyword, on Microsoft Learn.
