代码:
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
任何人都可以建议我如何转换此行:
ThreadReceive = New System.Threading.Thread(AddressOf ReceiveMessages)
VB到C#
谢谢,
巴沙
最佳答案
假设没有名称更改,这应该起作用:
ThreadReceive = new System.Threading.Thread(receiveMessage);
AddressOf
创建ReceiveMessages
的委托(delegate),这在C#中隐含。