Thanks for the clarification, in the end I've gone with a wrapper class (private declaration of XmlElement instead of inheritance) which loses all the native functionality of XmlElement, unfortunately.
I would like to extend the functionality of XmlDocument and XmlElement to make it easier to add new children, multiple values at once, etc, for example this function would be useful:
Public Function AddValues(paramarray NameThenValue() as object)
Dim x as XmlElement
Well the issue then is that what I"m casting from (XmlElement) actually isn't a SimpleXmlElement - that's the whole point. I'm taking the response from XmlElement.appendChild() (which is XmlElement) and I want to return it as SimpleXmlElement (derived class).
In fact there are no additional variables, only additional functions and subroutines. SimpleXmlElement is simply the addition of some shortcut functions to XmlElement, rather than adding any functionality.
Using this approach, I would effectively need to load the XML of the XmlElement passed...
Also for the record I have tried casting functions:
Public Shared Narrowing Operator CType(ByVal XmlElement As System.Xml.XmlElement) As SimpleXmlElement
I'm not sure what this contain, and anyway it produces this error:
"Conversion operators cannot convert from a...
Alternatively, can I get a derived class to set it's own MyBase? This way, SimpleXmlElement could accept XmlElement as a constructor parameter, set MyBase, and continue as normal. I don't really see why this shouldn't be possible. For example this would be ideal:
Public Class SimpleXmlElement...
OK I know this isn't supposed to be possible, because you can't be sure the object is really of the derived class (can't cast a mammal as a cat because it might be a dog, etc).
The thing is, I have a legitimate need to achieve this somehowand see no problem in this circumstance. I'm writing a...
I recently joined a new development team (developing mission critical financial services systems) and was horrified to find that they created XML using StringBuilder, and even worse sometimes, by string arrays & increments. Adjustments to XML were sometimes as terrible as stripping of last...
The code I posted was just to isolate the problem. The actual function I use is:
Public Function is_null(ByVal value As Object) As Boolean
Return (value Is Nothing) OrElse value.Equals(System.DBNull.Value)
Public Function check_string(ByVal value As Object, Optional ByVal...
Would that it were... not that simple! This code:
Public Class Form1
Public Function get_value(Optional ByVal alternative_value As String = "") As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As...
This wasn't the problem, however I've isolated it further. It's even stranger than I thought (though less of a problem, thankfully). Turns out the function is correctly returning an empty string when run in code, but returns Nothing (or appears to) when returning in the Immediate...
Weird. This code produces Nothing instead of "":
Public Function get_value(Optional ByVal alternative_value As String = "") As Object
dim d as object = get_value()
Why ideas why? It should return "" instead of Nothing as that's the parameter's...