[英]Converting AddressOf from VB6 to c#
在VB6中,我們有以下代碼。
g_CTimer.TimerID = SetTimer(0&, 0&, g_CTimer.Interval, AddressOf TimerProc)
TimerProc方法如下
Sub TimerProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long)
On Error Resume Next
If g_CTimer Is Nothing Then Exit Sub
g_CTimer.ThatTime
End Sub
我們如何在C#中轉換該調用“ AddressOf TimerProc”。
提前致謝。
關於阿基烏斯
在C#中,您可以省略AddressOf
關鍵字。 在VB.NET中,它明確暗示您將方法指針作為參數發送(在本例中為TimerProc
的指針)。 在C#中,您可以直接使用方法名稱。
就是說,您最好還是用一個普通的計時器( Windows.Forms.Timer
或其他計時器)重新實現它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.