序列化的int类型不带引号 [英] Serializing int type without quotes

查看:135
本文介绍了序列化的int类型不带引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下类是序列化:

[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?

推荐答案

本会的不可以是一个良好的XML了 - 你所定义的属性。

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

[XmlAttribute]

属性值总是在引号!

Attribute values are always in quotes!!

这篇关于序列化的int类型不带引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆