加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – xsd.exe属性顺序

发布时间:2020-12-15 21:44:13 所属栏目:百科 来源:网络整理
导读:我的目标是将c#类序列化为 XML,其属性顺序类似于我的类中的属性顺序.对于这个purporse,我需要在我的类中的其他属性之前添加System.Xml.Serialization.XmlElementAttribute(Order = int). [System.Xml.Serialization.XmlElementAttribute("F4INVAL",Form=Syst
我的目标是将c#类序列化为 XML,其属性顺序类似于我的类中的属性顺序.对于这个purporse,我需要在我的类中的其他属性之前添加System.Xml.Serialization.XmlElementAttribute(Order = int).

[System.Xml.Serialization.XmlElementAttribute("F4INVAL",Form=System.Xml.Schema.XmlSchemaForm.Unqualified,Order=1)]
    public F4invalType[] F4INVAL {
        get {
            return this.f4INVALField;
        }
        set {
            this.f4INVALField = value;
        }
    }

我有XSD文件(f4form_2012_3.xsd).

使用Xsd.exe(http://msdn.microsoft.com/en-en/library/x6c1kb0s.aspx)我执行此scriptlet来生成一组C#类:

xsd f4form_2012_3.xsd /order /classes

我需要使用C#属性[System.Xml.Serialization.XmlElementAttribute(Order = 1)]获取类属性.我这样做,但是第一类’属性有这个属性.

第二个和下面的类没有它.

请检查f4form_2012_3.cs

这是什么意思?

解决方法

这是因为您的F4ReportType复杂类型是XSD中使用xsd:sequence元素的唯一类型.您不能对从XML属性生成的属性进行排序,因为属性不是按XML排序的.也许您想要使用XML元素.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读