I'm new to C#10 and the default enabled nullable NRT functionality. In the following simple example I'm curious why VS2022 tells me (via tooltip) that o is object? when the interface definition explicitly states it is object.
Is this standard behavior and what's the reason for it? Is it because the compiler has no way of telling that the interface implementation is null-safe so has to assume the worst?
Further, s is also nullable (string?) but no warnings or errors are given when I use these nullable types. The compiler confidently informs me that "o is not null here" when I call o.ToString.
I can't tell at this stage if NRTs marks a paradigm shift to how we write modern C# or is "just another language tweak?" What's going on here? I want to 'embrace' it but am struggling with the full understanding of another change to the language.
public interface ITest
{
Object GetObject();
}
public class Tester
{
public void Test(ITest i)
{
var o = i.GetObject(); //object?
var s = o.ToString(); //string?
Console.WriteLine(s);
}
}




