Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,everyone

I create project web in VS2012,in line Error?

XML
XmlSerializer serializer = new XmlSerializer(this.GetType);


Error 2 The best overloaded method match for 'System.Xml.Serialization.XmlSerializer.XmlSerializer(System.Type)' has some invalid

Error 3 cannot convert from 'method group' to 'System.Type'


Thanks.
Posted

Try this
C#
XmlSerializer serializer = new XmlSerializer(typeof(name_of_the_class));
 
Share this answer
 
Change:
C#
XmlSerializer serializer = new XmlSerializer(this.GetType);

to
C#
XmlSerializer serializer = new XmlSerializer(this.GetType());

You get this error because
C#
Object.GetType()
is a method and not a property or variable.
http://msdn.microsoft.com/en-us/library/system.object.gettype(v=vs.110).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900