How can I check for null without using if
statement, in C#?
public class Bar {
public void foo() {
var discount = _discountService.GetDiscountById(discountId);
//this is anti pattern . is there any other way ?
if (discount == null)
throw new ArgumentException("Discount could not be loaded");
//main logic of methods continues here
}
}