Generic Way To Check a Variable is Null

Most of time we check a variable is Null or not. So below code snippet defines a generic way to check a variable is null. It will work with different variable type string, integer, custom object etc.
 
Here it defines a function CheckNullOrEmpty  with parameter value of Type T. This function returns boolean value(True) if variable is null otherwise False
  1. class Common 
  2. {    
  3.     
  4.    public static bool CheckNullOrEmpty<T>(T value)    
  5.    {    
  6.      if (typeof(T) == typeof(string))    
  7.         return string.IsNullOrEmpty(value as string);    
  8.     
  9.      return value == null || value.Equals(default(T));    
  10.    }    
  11.     
  12.     
  13.    public void TestFunc()    
  14.    {    
  15.     
  16.       bool f1 = CheckNullOrEmpty(""); //true    
  17.       bool f2 = CheckNullOrEmpty<string>(null); //true    
  18.       bool f3 = CheckNullOrEmpty(0); //true    
  19.       bool f4 = CheckNullOrEmpty<Stub>(null);  //true    
  20.    }    
  21. }