私のコード参照
var sample = DataContractDeserializeObject<MySample>(
"<MySample xmlns=\"http://schemas.datacontract.org/2004/07/Sample\"><Charecter>'D'</Charecter></MySample>");
When i run this code. i get this message "There was an error deserializing the object of type MySample. Content cannot be converted to the type Int. Line 1, position 129."
私の逆シリアル化コード
public static T DataContractDeserializeObject<T>(string objectToDeserialize)
{
using (XmlReader reader = XmlReader.Create(new StringReader(objectToDeserialize)))
{
var serializer =
new DataContractSerializer(typeof(T));
return (T)serializer.ReadObject(reader);
}
}
マイデータコントラクト
[DataContract]
public class MySample
{
[DataMember]
public char Charecter { get; set; }
}
char をデシリアライズする方法。ありがとう。