System.Type parameter

C

Claire

I'm calling a function that requires an object of class System.Type as a
parameter. The example I have shows the following.
System.Xml.Serialization.XmlSerializer reader = new
System.Xml.Serialization.XmlSerializer( this.GetType());

Can this be used without the "this.GetType()"? ie Can I pass in a Type
directly somehow. If so then how do I do it please.

eg

public MyClass = Class

{

}

System.Xml.Serialization.XmlSerializer reader = new
System.Xml.Serialization.XmlSerializer(MyClass)
 
D

Dennis Myrén

Yes, you can;
use
System.Xml.Serialization.XmlSerializer reader = new
System.Xml.Serialization.XmlSerializer(typeof(MyClass));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top