Skip to content

out var treated as non-nullable #25347

@cston

Description

@cston

out var is treated as non-nullable, regardless of parameter declaration.

class C
{
    static void TryGet(out string? s)
    {
        s = null;
    }
    static void Main()
    {
        TryGet(out var s); // string with null assignment warning
        int n = s.Length;  // no warning
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions