Joe,
But in the special case when the Object is a String I need to do something
extra.
Depending on how your function is structured you can use overloading in this
case also.
Public Sub DoSomething(ByVal x As String)
' special processing for a string
DoSomething(DirectCast(x, Object))
' more special processing for a string
End Sub
Public Sub DoSomething(ByVal x As Object)
' processing for a generic object
End Sub
The "DoSomething(DirectCast(x, Object))" forces the object version of the
function to be invoked.
Else where in your code when you:
Dim s as String
DoSomething(s)
The String version will be called. Where as when you:
Dim s As Object
DoSomething(s)
The Object version will be called.
Overloading in just another version of polymorphism that is useful.
However there are times when you do need to use If Typeof, which is why its
available also. As Gary stated, its good to limit its use...
Hope this helps
Jay