Can I use Operator_Convert() as ... on built-in classes?

I like to be able to write something like this:

dim d as new Date dim s as String = d // <- this is what I want to achieve, i.e. automatic conversion

Usually, with my own custom classes, I could add an Operator_Convert function to it, like this:

function Operator_Convert() as String return "x" end function

With built-in classes, this doesn’t work (it’s not feasible to make subclasses of them as I get them passed from other functions I do not control).

So I thought I could use the “extends” parameter attribute like this:

function Operator_Convert(extends d as Date) as String return d.SQLDateTime end function

But that doesn’t work - I get a TypeMismatchException at dim s as String = d.

Is there a way?


Oh, bummer. Well, then I can give up trying.

Could we agree that this is an incorrect behavior on part of the compiler, then? Similar to all the cases where it handles namespaces with nested modules wrong?

Operator_convert can’t be an extends method nor is in incorrect that it can’t