---
source: https://iinventedlight.com/library/notes/csharp-primary-constructors.md
title: "C# primary constructors"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0 (dotnet/docs); prose restates cited source lines"
attribution: "Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn (.NET docs), Declare C# primary constructors – classes, structs, CC BY 4.0 (dotnet/docs); Microsoft Learn (.NET docs), Instance constructors - C#, CC BY 4.0 (dotnet/docs)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No code was run for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-ai-eng: C#"
tags: ['csharp', 'dotnet', 'constructors', 'csharp-12']
sources:
  - id: S1
    title: "Declare C# primary constructors – classes, structs"
    publisher: Microsoft Learn (.NET docs)
    url: https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/primary-constructors
    accessed: 2026-11-04
    license: "CC BY 4.0 (dotnet/docs)"
  - id: S2
    title: "Instance constructors - C#"
    publisher: Microsoft Learn (.NET docs)
    url: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/instance-constructors
    accessed: 2026-11-04
    license: "CC BY 4.0 (dotnet/docs)"
---
# C# primary constructors

**Answer:** The parameters are in scope throughout the type body.

```csharp
public class OrderService(IOrderRepo repo, ILogger<OrderService> log) {
  public Order Get(int id) {
    log.LogInformation("Get {Id}", id);
    return repo.Find(id);
  }
}
```

## Other constructors must chain

Additional constructors must call the primary one with `this(...)`:

```csharp
public class Point(int x, int y) {
  public Point() : this(0, 0) {}
  public int X => x;
}
```

If a class has no explicit constructor, C# supplies a parameterless one; declaring a primary constructor replaces that default.

## Claims
- id: C1
  claim: C# 12 introduces primary constructors.
  source: S1
  evidence: "C# 12 introduces primary constructors"
- id: C2
  claim: Primary constructor parameters aren't members of the class.
  source: S1
  evidence: "Primary constructor parameters aren't members of the class."
- id: C3
  claim: Primary constructor parameters don't become properties, except in records.
  source: S1
  evidence: "Primary constructor parameters don't become properties, except in record types."
- id: C4
  claim: A constructor can call another using the this keyword.
  source: S2
  evidence: "To do that, use the this keyword."
- id: C5
  claim: C# provides a parameterless constructor if none is declared.
  source: S2
  evidence: "C# provides a parameterless constructor that you can use to instantiate an instance"

## Sources
- [S1] Declare C# primary constructors – classes, structs. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/primary-constructors . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.
- [S2] Instance constructors - C#. Microsoft Learn (.NET docs). https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/instance-constructors . License: CC BY 4.0 (dotnet/docs). Accessed 2026-11-04.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
