Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serializing int type without quotes

Tags:

c#

.net

I have the following class to be serializing:

[Serializable]
public class LabelRectangle { 
  [XmlAttribute]
  public int X { get; set; }
  [XmlAttribute]
  public int Y { get; set; }
  [XmlAttribute]
  public int Width { get; set; }
  [XmlAttribute]
  public int Height { get; set; }
}

and it is going to be serialized and looks like this

<LabelRectangle X="15" Y="70" Width="10" Height="1" />

but I would like to get the following result:

<LabelRectangle X=15 Y=70 Width=10 Height=1 />

that is serializing int type values without quotes. Is it possible and how if yes?

like image 584
Franziee Avatar asked Dec 03 '25 16:12

Franziee


1 Answers

this would not be a well formed XML anymore - you defined the Attribute

[XmlAttribute]

Attribute values are always in quotes!!

like image 51
Cadburry Avatar answered Dec 06 '25 05:12

Cadburry