Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# equivalent of VB.Net AddressOf Operator

Tags:

c#

vb.net

Code:

public Thread ThreadReceive;

ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
        ThreadReceive.Start()


    Public Sub ReceiveMessages()
        Try
            Dim receiveBytes As [Byte]() = receivingUdpClient.Receive(RemoteIpEndPoint)
            txtIP.Text = RemoteIpEndPoint.Address.ToString
            Dim BitDet As BitArray
            BitDet = New BitArray(receiveBytes)
        Catch e As Exception
            Console.WriteLine(e.Message)
        End Try
    End Sub

Can anyone Please Suggest me How to convert this line:

ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)

vb to C#

Thanks, Basha.

like image 241
user3075085 Avatar asked Dec 06 '13 16:12

user3075085


1 Answers

Assuming no name changes, this should work:

ThreadReceive = new System.Threading.Thread(receiveMessage);

AddressOf creates a delegate to ReceiveMessages and this is implied in C#.

like image 59
Austin Salonen Avatar answered Sep 19 '22 13:09

Austin Salonen