Variables with special characters

Asked

Viewed 320 times

2

Hello,

I’m trying to create a gender class:

[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 variables' names. Is there any way to get that symbol in the variables when it is serialized?

Thanks in advance.

  • And why you want this?

1 answer

4

Try to inform the alias via declaration of ownership 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; }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.