Coffeehouse Post

Single Post Permalink

View Thread: C# trivia question
  • User profile image
    cbae

    , DeathByVisualStudio wrote

    I work with guys I've shown things like ?? to but they still like writing statements like:

    1
    2
    3
    if (isDirty != null && isDirty == true){
         Save()
    }

    Forget the adoption of ??; comparing a Boolean? They say that it's more readable. Ug...

    (Ok, a nullable Boolean is a bad example but you get what I mean.)

    Ugh is right. Although if you didn't know what ?? does, this might be a little confusing to some:

    if (isDirty ?? false){     Save()}

    But that is when curiosity should lead you to find out WTF the ?? operator is for, and then you might actually learn something.