[XmlType(AnonymousType = true)]
Hello what does mean this line during serialization?
[XmlType(AnonymousType = true)]
public class classname
{
}
xsd.exe generates this for all classes. I read documentation, but still can't understand how it affects me if I remove this line.
开发者_开发问答Thanks,
It lets the compiler know whether or not to name the resulting XSD elements or make them anonymous
http://www.ibm.com/developerworks/library/xml-schema/
Elements with attributes must have a complex type
Now, try adding the attribute currency to the simple element price from Listing 7. You can't. An element of a simple type cannot have an attribute. If you want to add an attribute, you must define price as a complex type. In the example in Listing 8, we have defined what is called an anonymous type, where no explicit name is given to the complex type. In other words, the name attribute of the complexType element is not defined.
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmltypeattribute.anonymoustype.aspx
精彩评论