Mistaken nullable type inference (Nullable Reference Types)

51 Views Asked by At

Why is it that when I declare and initialize a variable using var, it's inferred type is nullable?

I've inserted a picture showing the object and Visual Studio's Tooltip.

Nullable Object

I would expect it's type to be object obj and not object? obj.

Project Setup excerpt

<PropertyGroup>
    <LangVersion>9</LangVersion>
    <TargetFramework>net5.0</TargetFramework>
    <Nullable>enable</Nullable>
</PropertyGroup>

I'm running Visual Studio 2019 (16.8.3) and Resharper is not installed.

0

There are 0 best solutions below