CSharp · Console
using System;
// see: https://stackoverflow.com/a/51268143/1016343
public class Program
{
public static void Main()
{
CustomClass c1 = null;
CustomClass c2 = new CustomClass();
bool b1 = c1; // is false
bool b2 = c2; // is true
if (!c1 && c2)
{
// Do stuff
"True".Dump();
}
}
}
public class CustomClass
{
public static implicit operator bool(CustomClass c)
{
if (c == null) return false;
else return true;
}
}