It's simple - x1
is not MyXElement
object! That's the same as trying following:
Dim o1 as Object = new Object()
Dim o2 as String
o2 = o1
The fact that String
inherits Object
does not mean you can assign Object
variable to String
It works the other way. You can easily write following:
Dim x1 As MyXElement = new MyXElement("name")
Dim x2 As XElement
x2 = x1