简体   繁体   English

C#中的地图类属性名称

[英]Map class property name in C#

I am sending to Azure Mobile Service Custom API method some information - object of class AddFriendRequest. 我正在向Azure移动服务自定义API方法发送一些信息-类AddFriendRequest的对象。

public class AddFriendRequest
{
    public string token { get; set; }
    public string uuid { get; set; }
}

Now I would like to change property 'token' to 'MY-TOKEN'. 现在,我想将属性“令牌”更改为“ MY-TOKEN”。 What I should use to change that property name without changing class object name, something like: 我应该用来更改属性名称而不更改类对象名称的东西,例如:

public class AddFriendRequest
{
    ["MY-TOKEN"]
    public string token { get; set; }
    public string uuid { get; set; }
} 

Depending on the method of serialization you could use the data contract: 根据序列化的方法,您可以使用数据协定:

[DataContract]
public class AddFriendRequest
{
    [DataMember(Name="MY-TOKEN")]
    public string token { get; set; }
    [DataMember]
    public string uuid { get; set; }
} 

I'm not sure if it is wise to have a hyphon in the name of a property. 我不确定以财产的名义使用hyphon是否明智。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM