2012-08-02 4 views
-3

VB에서 코드 조각을 번역하려고했지만 어떻게 해야할지 알 수 없습니다. 번역자가 누구인지 보여 줄 수 있습니까? VB로 VB #

는 이벤트를 처리하기 위해 별도의 방법을 만들어야합니다 있도록

private void WatchForDrives() 
{ 
    DeviceStatusMonitor monitor = new DeviceStatusMonitor(DeviceClass.FileSystem, false); 
    monitor.StartStatusMonitoring(); 
    monitor.DeviceNotification += delegate(object sender, DeviceNotificationArgs e) 
    { 
    string message = string.Format("Disk '{0}' has been {1}.", e.DeviceName,  e.DeviceAttached ? "inserted" : "removed"); 
    MessageBox.Show(message, "Disk Status"); 
    }; 
} 
+0

.NET의 버전은 무엇입니까? 그리고 단순한 인터넷 검색을 수행했다면 변환은 다소 사소한 것입니다. – Marlon

+0

감사합니다 ... 나는 그것을 시도했지만 작동하지 않습니다. 나는 Compact Framework 3.5 –

답변

1

만 VB (10)는, 여러 람다를 지원 감사드립니다. 컴파일러에 관계없이이 작업을 수행해야합니다.

Private Sub WatchForDrives() 
    Dim monitor As New DeviceStatusMonitor(DeviceClass.FileSystem, False) 
    monitor.StartStatusMonitoring() 
    AddHandler monitor.DeviceNotification, AddressOf MonitorDeviceNotified 
End Sub 

Private Sub MonitorDeviceNotified(ByVal sender As Object, ByVal e As DeviceNotificationArgs) 
    Dim message As String = String.Format("Disk '{0}' has been {1}.", e.DeviceName, If(e.DeviceAttached, "inserted", "removed")) 
    MessageBox.Show(message) 
End Sub 
+0

대단히 감사합니다. –

1

http://converter.telerik.com/

Private Sub WatchForDrives() 
    Dim monitor As New DeviceStatusMonitor(DeviceClass.FileSystem, False) 
    monitor.StartStatusMonitoring() 
    monitor.DeviceNotification += Function(sender As Object, e As DeviceNotificationArgs) Do 
     Dim message As String = String.Format("Disk '{0}' has been {1}.", e.DeviceName, If(e.DeviceAttached, "inserted", "removed")) 
     MessageBox.Show(message, "Disk Status") 
    End Function 
End Sub 
+0

덕분에 사용하고 있지만 작동하지 않습니다 ... "Do"문 다음에 오류가 발생합니다 –