I am not quite sure how to formulate this question, but the scenario is as follows:
Let's say I have the following class:
public class SampleClass
{
public int Number { get; set; }
}
I know that you can ignore the associated class:
SampleClass newSampleClass = possibleNullSampleClass ?? notNullSampleClass;
Is it possible to somehow execute some null coalesce property on the property, so I don't need to do this:
int? num = sampleClass != null ? new int?(sampleClass.Number) : 5;
It seems like it would be very helpful to have something like an operator ???to perform this check so that I can:
int? num = sampleClass.Number ??? 5;
Is something like this possible in C #?
source
share