Consider this code within my base class
public MyClass? Input { get; set; }
protected virtual void DoSomething()
{
Input = new();
}
Now I want to override the method and modify some properties on my Input property.
protected override void DoSomething()
{
base.DoSomething();
Input.Name = "Test";
}
Now I get the warning
CS8602 - Dereference of a possibly null reference.
I know I can say that it cannot be null be doing it like this:
Input!.Name = "Test";
But I don't want to do it everytime. Is there a better way to tell the compiler that Input is not null, when the base of the function has already been executed?