#9626·csharplang

[Proposal]: Target-typed generic type inference

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

Target-typed generic type inference

Summary

Generic type inference may take a target type into account. For instance, given:

csharp
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:

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

Design meetings