Hello experts,

Is it possible to call a vb delegate in C#? I have a sample vb code
that looks like this:

1) first I declared a delegate

Public Delegate Sub MessageDelegate(ByVal MsgString As String)

2) then the actual method:

Public Sub addToList(ByVal MsgString As String)
        ListBox.Items.Add(MsgString)
End Sub

3) then on my button click event I did this:

Private Sub btnAddItems_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnAddItems.Click
        Dim localEntry As New MessageDelegate(AddressOf addToList)
        localEntry.Invoke(txtLocal.Text.Trim())
End Sub

What I want to do now is to somehow "export" the localEntry variable
to my c# code (a *.dll) which looks like this:

        public void exportDelegate(Delegate AVBDelegate)
        {
            if (AVBDelegate != null)
            {
                 // what should I type here?
            }
        }

I learned that to use delegates you use Invoke(). I just found out
that there's a method called "DynamicInvoke". I tried to use that in
the C# side of the code but got a runtime exception.
Forgive me for my ignorance. I just don't have an idea yet of what it
does. :)

Can someone help? Thanks in advance!


Benj












Reply via email to