When i serialize class object, the result was contains int properties and their value is 0. Can i delete this row in xml?
public class Animal
{
public int Id { get; set; }
public string Name { get; set; }
}
class Program
{
public static void Main(string[] args)
{
Animal aminal = new Animal();
using (TextWriter writer = new StreamWriter(@"C:\resultAnimal.xml"))
{
serializer.Serialize(writer, animal);
}
}
}
result.xml
<?xml version="1.0" encoding="utf-8"?>
<Animal>
<Id>0</Id>
</Animal>
i want result.xml this format
<?xml version="1.0" encoding="utf-8"?>
<Animal>
</Animal>
No comments:
Post a Comment