Thursday, July 19, 2012

Check if object is null

If you use the method below, 

public static implicit operator bool(Object exists){
       return exists == null;
       }

you can then use this code,
if (p2p){
}

instead of this code:

if (p2p == null){
}

Having said all that, this is a horrible idea, breaks C# conventions, and will create creepy bugs later on. So do not use it.

No comments: