I am sure this is a very useful thing, but I can not find the information ...
I have an Obejct series serializer and deserialization that occurs in my program. Objects have fields with a null value, one of which is the DefaultValue field and is a reference to the object.
When this object reference is null before serialization, the deserialized object contains a reference to an empty object.
What is the best way to detect this empty object? Comparison with null termination, because it refers to an empty System.Object, as well as comparison with a new object.
Some pseudo codes to highlight my problem ....
class MyObj
{
public object DefaultValue {get; set;}
public object AnotherValue {get; set;}
}
class Program
{
internal static void Main()
{
MyObj obj = new MyObj();
obj.AnotherValue = "Some String";
String serialisedObject = Serialise(obj);
MyObj deserialisedObj = Deserialise(serialisedObject);
if (deserialisedObj.DefaultValue != null)
{
String default = deserialisedObj.DefaultValue.ToString();
}
}
}
source
share