I have a list of an object, I want to update all the fields that are null to string.empty.
here is the code:
public class Class1
{
public string P1 { get; set; }
public string P2 { get; set; }
public string P3 { get; set; }
}
I want to have a code which goes and find all the null values in all the fields and change the value to string.empty
static void Main(string[] args)
{
var list= new List<Class1>();
var class1 = new Class1 {P1 = "P1-1", P2 = "P2-1", P3="null"};
list.Add(class1);
var class2 = new Class1 { P1 = "P1-2", P2 = "P2-2", P3 = "null" };
list.Add(class2);
}
so I would need the class1.P3 and class2.P3 to be found and their value to be replaced.
Thanks
Aucun commentaire:
Enregistrer un commentaire