Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

C# CS7036: no argument given that corresponds to the required parameter

CS7036 means the chosen constructor or method expects an argument the caller skipped. Match the signature instead of casting or adding a null default.

~5 min readC#
#csharp#dotnet#cs7036#constructors
Bold white headline reading MISSING ARGUMENT with a .NET constructor crate showing an empty amber parameter slot on the right.

Introduction & Quick Summary

The compiler rejects a call site rather than the declaration:

code
error CS7036: There is no argument given that corresponds to the required parameter 'name' of 'Person.Person(string)'

The constructor, method, or base call exists, was found unambiguously, and expects a parameter that the call site did not supply. Unlike CS1729 ("does not contain a constructor that takes 0 arguments"), CS7036 means the chosen overload is close enough to select and then found short of arguments — usually because a parameter was added, renamed into an optional pair, or never had a default value to begin with.

Quick answer, in the order that matches intent most often:

csharp
new Person("ada"); // pass the argument the signature requires public Person(string name = "unknown") { } // or give the parameter a default public required string Name { get; init; } // or move to required properties

Which one is correct depends on whether the value is genuinely mandatory. A default of "" or null that the constructor immediately rejects is worse than a compile error, so prefer required properties when the value must be supplied but has no sensible default.

Where it commonly appears: a constructor gained a dependency during a refactor, a base class constructor was added while the derived class still relies on the implicit one, a record's positional parameters were converted to properties, and dependency injection code passes an argument array that no longer matches the constructor.

Core Mechanics, Signatures & Reproducible Setup

C# overload resolution picks the best candidate and then checks arguments. A missing argument is not a type mismatch, so the error names the parameter, not the call:

code
class Person { public Person(string name) { } } var p = new Person(); // CS7036: required parameter 'name'

Reproduce the three shapes that produce the same message:

csharp
public class A { public A(string name) { } // 1. no default public A(string name, int age = 0) { } // 2. optional trailing public A(string name = "x", int age = 0) { } // 3. fully optional } public class B : A { public B() { } // CS7036: base A has no parameterless ctor public B(string name) : base(name) { } // fixed } _ = new A(); // matches 3; CS7036 if only 1 and 2 exist _ = new A(age: 30); // CS7036: 'name' still required

The message always has the form required parameter 'p' of 'Type.Member(signature)', so the type and the member are unambiguous. When several candidates exist and one has a default, the compiler may pick the wrong one and then complain; -Xdiags-style detail is not available in C#, but the IDE's candidate list shows which overload was chosen.

Optional parameters have one hard rule: they must come after every required parameter in the same signature, and their default must be a compile-time constant (null for reference types, a numeric or string literal, default, or an enum member). Violating the ordering rule is CS1737, a different error that appears alongside CS7036 during a signature change.

RuleValidInvalid
optional after requiredvoid F(int a, int b = 0)void F(int a = 0, int b)
default is a constant= null, = 0, = "x", = default= DateTime.Now
default resolves per static typeIGreeter g; g.Greet()new Greeter().Greet()

Key Comparison Table

Forms that supply a value without a constructor argument, and whether callers must pass something:

DeclarationCaller must passNotes
public Person(string name)yesclassic required parameter
public Person(string name = null)nodefault is baked into call sites at compile time
public required string Name { get; init; }yes, at object initialisationC# 11+, error is CS9035
public record Person(string Name)yes, positionally or by namepositional parameters become properties
public class Person(string name)yes for the primary constructorC# 12+, parameters are captured, not properties
public Person() { } plus settable propertynovalidation moves to runtime

Neighbouring errors, and what each actually reports:

ErrorMeaningDifference from CS7036
CS7036a selected overload is missing an argumentthe signature was found
CS1729no constructor with that argument count existsno candidate survived
CS1501no overload for method takes N argumentsmethod group, not a constructor
CS1739the best overload has no parameter named 'x'named argument typo
CS0121the call is ambiguoustwo candidates equally good
CS9035a required member was not setobject initialiser, not a call

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Derived classes must call the base constructor explicitly

csharp
public class Repository { protected Repository(string connectionString) { } } public class UserRepository : Repository { public UserRepository() : base("Server=.;Database=app") { } // required }

Once a base class declares only parameterless-less constructors, every derived class needs a : base(...) call. Adding a constructor to a base class is therefore a breaking change across an assembly, and the compiler reports it at every derived class rather than at the call sites — which is the good outcome.

2. Named arguments and reordering

csharp
public static void Send(string to, string subject, string body, bool html = true) { } Send(to: "a@b.c", subject: "hi", body: "text"); // fine, html defaults Send(subject: "hi", body: "text"); // CS7036: 'to' still required Send(to: "a@b.c", subject: "hi", body: "text", html: true);

Named arguments may appear in any order, but they cannot skip a required one. A refactor that renames body to content produces CS1739 at call sites that use the name and CS7036 at those that pass positionally and now fall short, which together are a reliable signal that the rename is not finished.

3. Records and primary constructors

csharp
public record Person(string Name, int Age); var a = new Person("ada", 36); var b = new Person(Name: "ada", Age: 36); // var c = new Person("ada", age: 36); // CS7036: 'Age' not supplied

A positional record's parameters are all required unless declared with a default: public record Person(string Name, int Age = 0);. Converting a record to a class with properties does not keep the constructor automatically — the positional constructor disappears, and every new Person("ada", 36) becomes CS7036 until you add one or switch to an initialiser.

4. Dependency injection and ActivatorUtilities

csharp
public sealed class ReportService { public ReportService(ILogger<ReportService> logger, IClock clock) { } } // runtime equivalent: the argument array must cover non-registered parameters var svc = ActivatorUtilities.CreateInstance<ReportService>(provider, clock);

ActivatorUtilities fills what the container knows and takes the rest from the array. A constructor parameter that is neither registered nor passed throws an InvalidOperationException at runtime, not CS7036 — so a green build is no proof that the wiring is complete. Add a test that resolves the service from the container.

5. Interfaces, defaults and optional parameters

csharp
public interface IGreeter { string Greet(string name = "world"); } public class Greeter : IGreeter { public string Greet(string name) => $"hello {name}"; // legal, default not repeated }

The default lives on the static type of the call: IGreeter g = new Greeter(); g.Greet() compiles, while new Greeter().Greet() produces CS7036. The interface member supplies the default, not the implementation.

6. Stale build artefacts

A signature change that is correct in source can still surface CS7036 through a referenced project compiled before the change. Clean the intermediate output rather than reasoning about it:

bash
dotnet clean && rm -rf obj bin && dotnet build

Multi-targeting projects keep separate obj trees, and a failure in one target frame and not the other points at conditional compilation rather than at the constructor.

Common Compilation/Runtime Mistakes & Version Gotchas

Adding = null to silence the error. For a non-nullable string parameter this trades a compile-time guarantee for a runtime NullReferenceException, and callers compiled against the old signature keep the old default baked in until rebuilt.

Changing a public constructor's defaults in a library. Default values are inlined into call sites at compile time, so applications that were not recompiled keep the old values with no error anywhere.

Confusing params with optional parameters. void Log(string format, params object[] args) accepts zero extra arguments and never raises CS7036; a method with object[] args and no params keyword requires an array.

Version differences. required members arrived in C# 11 and report CS9035 rather than CS7036, which is why search results for the older error do not match. Primary constructors for classes arrived in C# 12; their parameters are captured like locals and are not properties, so person.Name fails while person.Name from a positional record works. Records with positional parameters have existed since C# 9, and init accessors since C# 9 as well — both change which form of construction a codebase uses. .NET Framework projects with an older LangVersion reject required and init outright, which surfaces as a syntax error rather than an argument error.

Checking the actual call shape. When a call site is generated (source generators, dynamic, reflection), print the invocation instead of reading the generator. Serialising the argument object with the JSON formatter shows exactly which keys were present, and diffing two generated files with the text diff tool reveals a parameter that disappeared between builds.

Reference material: Constructors in C# and Named and optional arguments.

Official references

primary documentation

The C# documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit C# work — they run entirely in this browser tab, so nothing you paste leaves your device.

All C# guides

More in C#

All C# guides

The guides filed next to this one in C#, in library order.