0

好的,我确定这一定非常容易,但我找不到有关此事的信息。

另外,这是我第一次使用 WCF,所以如果我对事物的理解有点慢,请放轻松。

假设我有这门课

[DataContract]
public class whatever {

    [DataMember]
    public string whateverName;

    [DataMember]
    public string whateverId;

}

这将序列化为:

<whatever>
    <whateverName></whateverName>
    <whateverId></whateverId>
</whatever>

如何更改它以进行以下序列化?

<whatever whateverName="" whateverId="" />
4

1 回答 1

1

您可以使用下面提到的代码,例如

[DataContract]
public class whatever
{
  [XmlAttribute]
  public string whateverName;

  [XmlAttribute]
  public string whateverId;
}
于 2015-11-18T09:13:31.730 回答