开发者

DataContract & DataMember attributes - how they affect type

what is the difference between class without DataContract attributes:

public class BankOperationResult
{        
    public int CurrentAmount { get; set; }
    public bool Success { get; set; }
}

and the same class开发者_StackOverflow社区 with DataContract attributes:

[DataContract]
public class BankOperationResult
{        
    [DataMember]
    public int CurrentAmount { get; set; }
    [DataMember]
    public bool Success { get; set; }
}

I mean, does WCF treats those two types in different way when encoding etc.?

With or without those attributes my WCF service works...

Thanks, Pawel


Before .NET 3.5 SP1 if you didn't mark your property with a DataMember attribute it was not exposed in the WSDL and not serialized. Starting from .NET 3.5 SP1 the DataContractSerializer will automatically include all public properties, so you no longer need to decorate them with this attribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜