0

Ok, I'm sure this must be terribly easy, but I cannot find info into the matter.

Also, it's my first time using WCF, so get easy on me if I'm a bit slow understanding things.

Let's say I have this class

[DataContract]
public class whatever {

    [DataMember]
    public string whateverName;

    [DataMember]
    public string whateverId;

}

This will serialize into:

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

How can I change it to make the following serialization?

<whatever whateverName="" whateverId="" />
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Bardo
  • 2,470
  • 2
  • 24
  • 42

1 Answers1

1

You can use below mentioned code like

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

  [XmlAttribute]
  public string whateverId;
}
Dhaval Patel
  • 7,471
  • 6
  • 37
  • 70
  • Please, check http://stackoverflow.com/questions/33779824/wcf-xmlserializerformat-doesnt-parse-class-type for further explanation on the whole problem – Bardo Nov 18 '15 at 12:17