Created
January 6, 2017 17:03
-
-
Save lruckman/5831eadf25417171241e1cc0efcece2e to your computer and use it in GitHub Desktop.
Serialization issue when property is set to null
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
public class Foo | |
{ | |
public string MyStr { get; set; } | |
} | |
static void Main(string[] args) | |
{ | |
var serializer = new ExtendedXmlSerializer(); | |
Console.WriteLine("Missing MyStr node in XML:"); | |
Console.WriteLine(serializer.Serialize(new Foo { MyStr = null })); | |
Console.WriteLine("----"); | |
Console.WriteLine("Constains MyStr node in XML"); | |
Console.WriteLine(serializer.Serialize(new Foo { MyStr = "" })); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment