System.Type parameter

  • Thread starter Thread starter Claire
  • Start date Start date
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)
 
Yes, you can;
use
System.Xml.Serialization.XmlSerializer reader = new
System.Xml.Serialization.XmlSerializer(typeof(MyClass));
 
Back
Top