In JavaScript there is the idea of truthy and falsy values.

e.g.

  • 0 : Always false
  • 1 : Always true
  • '0' : Always true
  • '1' : Always true

Is there an equivalent list of truthy and falsey values in the C# language on the .NET framework?

The reason I would like to know this is that I find myself doing the following

if(obj != null)
{
   // Do something with the object
}

When I could write the following

if(obj)
{
   // Do something with the object
}
Edit
Report