I suggest you ...

Boolean coercion in c#

Can't believe this isn't a request already, but probably my biggest annoyance.

I really should be able to do

if(someObj)
someObj.Something();

rather than having to do

if(!Object.ReferenceEquals(null, someObj))
someObj.Something();

It doesn't have to do full javascript-style coercion (though extensiblity would be swell), just a simple != null check would cover 99% of scenarios.

16 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    George MauerGeorge Mauer shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    4 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Hadrien ThomasHadrien Thomas commented  ·   ·  Flag as inappropriate

        And what would do:

        if(obj && boolean) ?

        Javascript has so lazy notations and behaviour that it's the most bugged language in the world.
        Let's not take anything from it.

      • George MauerGeorge Mauer commented  ·   ·  Flag as inappropriate

        Right, sure, if you prefer to do != null to allow for operator overriding then sure, we can do that, but the point is to have the implicit conversion so you don't have to do the comparison explicitly

      Feedback and Knowledge Base