C# to VB.NET IClonable

  • Thread starter Thread starter AMerrell
  • Start date Start date
A

AMerrell

Hello,

There is a C# funciton I'm trying to translate that clones some event handlers.

public virtual object Clone()
{
...... Instance of a Custom Collection .......
myCol.ItemAdded = this.ItemAdded;
myCol.ItemRemoved = this.ItemRemoved;
return myCol;
}

In VB.NET I have this.

Public Overridable Function Clone() As Object Implements ICloneable.Clone
...... Instance of a Custom Collection .......
myCol.ItemAdded = me.ItemAdded
myCol.ItemRemoved = me.ItemRemoved
return myCol
End Function

The system tells me I need to use a 'RaiseEvent' statement to raise an event.

How do I go about doing the same thing in VB.NET that was done in C#?

Thank You
AM
 
Hi,



AddHandler myCol.ItemAdded, AddressOf Me.ItemAdded gives me 'AdressOf' operand must be the name of a method; no parantheses are needed.


Not sure why it mentions parantheses since the are none.

Thanks,
AM
 
Because Me.ItemAdded must be a sub or a function.
myCol.ItemAdded must be an event declaration.


Public Class Col

Public Event ItemAdded()

End Class



Public Class Clones

Sub ItemAdded()

End Sub



Function Clone() as Object

....

AddHandler myCol.ItemAdded, me.ItemAdded

return myCol

End Function

End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top