Check if object is null using ReferenceEquals object static method.

Posted by Vishalneeraj-24503 under Visual Studio category on | Points: 40 | Views : 202
public bool IsNull(object obj)
//ReferenceEquals - >Determines whether the specified System.Object instances are the same instance.
return object.ReferenceEquals(obj, null);

string st = null;
Response.Write(IsNull(st) + "<br/>"); //True
st = "1";
Response.Write(IsNull(st) + "<br/>"); //False

Comments or Responses

Login to post response