Armin Zingler replied to Armin Zingler
21-Nov-09 06:58 AM
Armin Zingler schrieb:
When I wrote the 2nd part of my answer, I was not aware of Option Strict Off, yet.
I misread it and assumed a compile time error but you mentioned an exception. Sorry,
my fault.
Well, with Option Strict On, you do not get an exception, so I think this changed
the situation. But, you can also not write
Dim data2 As String = CType(obj, String) 'failure
because it is the compiler that is responsible for making use of your own operator.
it is not used in this case because the expression type is Object, not MyOpTest.
So you would have to write
Dim data2 As String = CType(DirectCast(obj, myoptest), String)
--
Armin