[XmlType(AnonymousType = true)]

Ale*_*lov 12 c# serialization attributes

你好,序列化期间这行是什么意思?

[XmlType(AnonymousType = true)]
public class classname
{
}
Run Code Online (Sandbox Code Playgroud)

xsd.exe为所有类生成此.我阅读了文档,但是如果删除这一行,仍然无法理解它对我的影响.

谢谢,

Mik*_*ike 9

它允许编译器知道是否命名生成的XSD元素或使它们匿名

http://www.ibm.com/developerworks/library/xml-schema/

具有属性的元素必须具有复杂类型

现在,尝试将属性货币添加到清单7中的简单元素价格.您不能.简单类型的元素不能具有属性.如果要添加属性,则必须将价格定义为复杂类型.在清单8的示例中,我们定义了所谓的匿名类型,其中没有为复杂类型指定显式名称.换句话说,未定义complexType元素的name属性.

http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmltypeattribute.anonymoustype.aspx