How to check if an object is null
<p>Here is my code:</p>

<pre><code>public static class SerializationUtil
{
    public static string Serialize(object obj)
    {
        if (obj == null)
            return string.Empty;

        StringWriter writer = new StringWriter();
        new System.Web.UI.LosFormatter().Serialize(writer, obj);
        return writer.ToString();
    }

    public static object Deserialize(string data)
    {
        if (data == null)
            return null;
        return (new System.Web.UI.LosFormatter()).Deserialize(data);
    }
}
</code></pre>

<p>The problem I am having is: When I call the serialize method if the obj is null it throws an error. So i would like to check if the obj value is null or not. The code I have i place now does not work as when the obj value is checked its never null.</p>

<p><strong>Resolved:</strong></p>

<p>See my post in answers</p>
