代码:
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#
谢谢, 岜。
答案 0 :(得分:10)
假设没有更改名称,这应该有效:
ThreadReceive = new System.Threading.Thread(receiveMessage);
AddressOf
创建了ReceiveMessages
的委托,这在C#中暗示。
答案 1 :(得分:1)
ThreadReceive = new System.Threading.Thread(ReceiveMessages);
其中ReceiveMessages
是void
类型的方法。