Delegate question.

  • Thread starter Thread starter Noor
  • Start date Start date
N

Noor

Hi

when i declare a delegate like

"Private Delegate Function operation(ByVal x As Integer, ByVal y As Integer)
As Integer"

and I also have method that matches this delegate signature like.

"Private Function add(ByVal x As Integer, ByVal y As Integer) As Integer

Return x + y

End Function"

Then,

I can assign the method to delegate reference variable in two ways and both
the ways work fine, like

1) dim delOp As operation
delOp = New operation(AddressOf add)

delOp(1,2)


2) dim delOp as operation
delOp = AddressOf add

delOp(2,4)


I want to ask what's the difference between both the method.

Thanks

Noor
 
Hi Noor,

no real difference between them. The second is just shorthand for the first.

Bill.
 
Back
Top