#9627·csharplang

[Proposal]: Target-typed inference for constructor calls

Author: MadsTorgersenCreated Aug 22, 2025Updated Sep 1, 2026
LabelsProposal champion

Target-typed inference for constructor calls

Summary

Generic type inference is extended to 'new' expressions, which may infer type arguments for the newly created class or struct, including from a target type if present. For instance, given:

csharp
public class MyCollection<T> : IEnumerable<T>
{
    public MyCollection() { ... }
    ...
}

We would allow the constructor to be called without a type argument when it can be inferred from arguments or (in this case) a target type:

csharp
IEnumerable<string> c = new MyCollection(); // 'T' = 'string' inferred from target type

Design meetings