How to get type of class without initiating object?
-
13-10-2019 - |
سؤال
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?
المحلول
Try this:
Dim xmlszer As New XmlSerializer(GetType(AnyClass))
Returns a
Type
object for the specified type. TheType
object provides information about the type such as its properties, methods, and events.
نصائح أخرى
Try this instead ;)
Dim xmlszer As New XmlSerializer(GetType(MyClass))
لا تنتمي إلى StackOverflow