public class Person
{
public string? Name { get; set; }
public void SetName(string value) { Name = value; }
}
Then it's used like this. If the reference to person is null it will skip it.
Person person = null;
person?.SetName("John Doe");
Console.WriteLine(person?.Name);