A
Armin Zingler
Hi,
why do Extensions not work for references of type 'Object'?
It's only available for all other types. One (huge) example:
<Extension()> _
Public Function Cast(Of TResult)(ByVal var As Object) As TResult
Return DirectCast(var, TResult)
End Function
But:
Dim c As Control = New Form
Dim o As Object = c
Dim f As Form
f = c.Cast(Of Form)() 'works
f = o.Cast(Of Form)() '-----> does not work <------
Is there a reason for this limitation that I'm unable to see?
why do Extensions not work for references of type 'Object'?
It's only available for all other types. One (huge) example:
<Extension()> _
Public Function Cast(Of TResult)(ByVal var As Object) As TResult
Return DirectCast(var, TResult)
End Function
But:
Dim c As Control = New Form
Dim o As Object = c
Dim f As Form
f = c.Cast(Of Form)() 'works
f = o.Cast(Of Form)() '-----> does not work <------
Is there a reason for this limitation that I'm unable to see?