I am trying to serialize an object and the \0 (Null) character is being appended to the generated string. Why?
My code:
XmlSerializer serializer = new XmlSerializer(typeof(Common.PlanogramSearchOptions));
MemoryStream memStream = new MemoryStream();
serializer.Serialize(memStream, searchOptions);
string xml = Encoding.UTF8.GetString(memStream.GetBuffer()); // appends \0
My work around is replacing the Null character with an empty string
xml.Replace("\0", string.Empty)
Thanks.