ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

IsNotNull

This method returns true if the value if not null otherwise it returns false.

Source

public static bool IsNotNull<T>(this T input)
{
   var output = false;
   if(null != input)
   {
      output = true;
   }
   return output;
}

Example

var stringBuilder = new StringBuilder();

if(stringBuilder.IsNotNull())
{
   //yeah, it's not null
}

Author: Omkar Panhalkar

Submitted on: 7 mei 2012

Language: C#

Type: System.Type

Views: 5006