I have the following xml that contains a white space Field1Value . When I deserialize that xml I lose the single space character. The value of Request.Field2 is "". Is this a bug in the xml serializer? Can anyone recommend a solution/ workaround to keep this space?
...
var encoding = new System.Text.UTF8Encoding();
var _xmlData = "<Request><Field1>Field1Value</Field1><Field2> </Field2></Request>";
var _xmlDataAsByteArray = new byte[_xmlData.Length];
_xmlDataAsByteArray = encoding.GetBytes(_xmlData);
var _memoryStream = new MemoryStream(_xmlDataAsByteArray);
var _XmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Request));
Request _request = _XmlSerializer.Deserialize(_memoryStream) as Request;
...
public class Request
{
public string Field1;
public string Field2;
}