2016-04-19 27 views
0

我有一些类,例如:如何在序列化器生成的xml中插入注释?

Public Class MyClass 
    Public Property MyProperty As Integer = 1 
End Class 

串行(Xml.Serialization.XmlSerializer)创建XML:

<?xml version="1.0" encoding="utf-8"?> 
<MyClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <MyProperty>1</MyProperty> 
</MyClass> 

我怎样才能从串行财产以后这样得到:

<?xml version="1.0" encoding="utf-8"?> <MyClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
    <!-- Use positive values less than 10 --> 
    <MyProperty>1</MyProperty> 
</MyClass> 

谢谢!

+4

看[本SO问题](http://stackoverflow.com/questions/7385921/how-to-write -a注释到一个-XML的文件时,使用最XmlSerializer的) – Icemanind

回答

0

尽量利用 [XMLCOMMENT(VALUE = “您的评论”)]属性