Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get type of class without initiating object?

The consturctor of System.Xml.Serialization.XmlSerial need the type of the class I want to serialize.

instance = New AnyClass()
Dim xmlszer As New XmlSerializer(instance.GetType)

No problem. But how can I get the type of AnyClass without initiating?

like image 984
rakete Avatar asked Jan 20 '11 13:01

rakete


1 Answers

Try this:

Dim xmlszer As New XmlSerializer(GetType(AnyClass))

GetType Operator:

Returns a Type object for the specified type. The Type object provides information about the type such as its properties, methods, and events.

like image 148
Andrew Hare Avatar answered Sep 20 '22 16:09

Andrew Hare