optimization - Does C# know to optimize Null Conditional Operators in multiple condition statements? -
i have following code:
var reportdate = (model.from?.year == null || model.from?.month == null || model.from?.day == null) ? datetime.utcnow.date : new datetime(model.from.year.value, model.from.month.value, model.from.day.value); note conditional expression, better write
(model.from == null || model.from.year == null || model.from.month == null || model.from.day == null) so won't model.from null check every performed == operator? compiler know how optimize former code check model.from null once?
Comments
Post a Comment