[Proposal]: Target-typed generic type inference
Author: MadsTorgersenCreated Aug 22, 2025Updated Sep 1, 2026
LabelsProposal champion
Target-typed generic type inference
- Specification: https://github.com/dotnet/csharplang/blob/main/proposals/target-typed-generic-type-inference.md
- Discussion: https://github.com/dotnet/csharplang/discussions/9628
Summary
Generic type inference may take a target type into account. For instance, given:
public class MyCollection
{
public static MyCollection<T> Create<T>() { ... }
}
public class MyCollection<T> : IEnumerable<T> { ... }We would allow the Create method to be called without type argument when it can be inferred from a target type:
IEnumerable<string> c = MyCollection.Create(); // 'T' = 'string' inferred from target typeDesign meetings
- https://github.com/dotnet/csharplang/blob/main/meetings/2025/LDM-2025-08-18.md#type-inference
- https://github.com/dotnet/csharplang/blob/main/meetings/2025/LDM-2025-08-20.md#target-type-inference-improvements
- https://github.com/dotnet/csharplang/blob/main/meetings/2026/LDM-2026-08-19.md#type-parameter-inference-for-constructor-calls
Source: dotnet/csharplang