Variables with special characters

2

Hello,

I'm trying to create a class of the genre:

[DataContract, Serializable]
public class XMLCM5050 : XmlApi
{
    [DataMember]
    public string $name{ get; set; }

    [DataMember]
    public string $age{ get; set; }
}

I know it's not possible to add the "$" symbol to the variable name. Is there any way to get this symbol in the variables when it is serialized?

Thank you in advance.

    
asked by anonymous 01.10.2015 / 15:39

1 answer

4

Try to inform the alias via declaration of property Name of DataMember :

[DataContract, Serializable]
public class XMLCM5050 : XmlApi
{
    [DataMember(Name="$name")]
    public string name{ get; set; }

    [DataMember(Name="$age")]
    public string age{ get; set; }
}
    
01.10.2015 / 15:42