O
OpticTygre
Ok, so I've been trying and trying to learn about delegates, but I still
can't grasp the concept of the advantages. Why use delegate functions
instead of calling the function directly?
In other words, if I had something like:
---------------------------------------------
Public Class ProductList
Public Function GetTotal() as Decimal
'Code omitted
End Function
End Class
---------------------------------------------
And then something like:
---------------------------------------------
Public Delegate Function GetTotalDelegate() as Decimal
Dim List As New ProductList()
Dim GetTotalPointer As New GetTotalDelegate(AddressOf List.GetTotal)
Dim Total As Decimal
Total = GetTotalPointer()
---------------------------------------------
Why use a delegate call instead of just saying Total =
ProductList.GetTotal() ?????
Thanks for any explanations
-Jason
can't grasp the concept of the advantages. Why use delegate functions
instead of calling the function directly?
In other words, if I had something like:
---------------------------------------------
Public Class ProductList
Public Function GetTotal() as Decimal
'Code omitted
End Function
End Class
---------------------------------------------
And then something like:
---------------------------------------------
Public Delegate Function GetTotalDelegate() as Decimal
Dim List As New ProductList()
Dim GetTotalPointer As New GetTotalDelegate(AddressOf List.GetTotal)
Dim Total As Decimal
Total = GetTotalPointer()
---------------------------------------------
Why use a delegate call instead of just saying Total =
ProductList.GetTotal() ?????
Thanks for any explanations
-Jason