I have few classes with a number of properties. Value to these properties would be assigned based on certain conditions. After the values are assigned to few of the properties, I would like to serialize the object and include only those props that have value assigned to them.
I have tried searching for this on Internet but I could not find any luck.
Any suggestion on implementing this would be highly appreciated.
Update:
I have some classes like
class A{
public static string PropA_in_A { get; set; }
public string PropB_in_A { get; set; }
public static string PropC_in_A { get; set; }
public static string PropD_in_A { get; set; }
}
class B{
public static string PropA_in_B { get; set; }
public static string PropB_in_B { get; set; }
public static string PropC_in_B { get; set; }
public static string PropD_in_B { get; set; }
}
class C{
public static string PropA_in_C { get; set; }
public static string PropB_in_C { get; set; }
public static string PropC_in_C { get; set; }
public static string PropD_in_C { get; set; }
}
Values to the Properties in these classes need to assigned based on conditions. After the values are assigned , only those properties need to be serialized that have values assigned to them.
main()
{
A.PropB_in_A="Some Value";
A.PropA_in_B="Some Value";
A.PropC_in_C="Some Value";
}
Here , I would like to serialize only those properties have values assigned to them.