How can I create a generic constructor? (ie. BaseClass.FromXml(<param>)
- by SofaKng
I'm not sure how to describe this but I'm trying to create a base class that contains a shared (factory) function called FromXml. I want this function to instantiate an object of the proper type and then fill it via an XmlDocument.
For example, let's say I have something like this:
Public Class XmlObject
Public Shared Function FromXml(ByVal source as XmlDocument) As XmlObject
// <need code to create SPECIFIC TYPE of object and return it
End Function
End Class
Public Class CustomObject
Inherits XmlObject
End Class
I'd like to be able to do something like this:
Dim myObject As CustomObject = CustomObject.FromXml(source)
Is this possible?