我需要将此代码转换为vb.net
public IDisposable WriteLock()
{
EnterWriteLock();
return new LockDisposer(delegate() { ExitWriteLock(); });
}
这是我通过在线转换器获得的
Public Function WriteLock() As IDisposable
EnterWriteLock()
Return New LockDisposer(Sub() ExitWriteLock()) <-- Error Line
End Function
我正在使用.net 2.0
答案 0 :(得分:2)
Public Function WriteLock() As IDisposable
EnterWriteLock()
Return New LockDisposer(AddressOf ExitWriteLock)
End Function
答案 1 :(得分:-1)
您的代码缺少委托的结尾子:
Public Function WriteLock() As IDisposable
Return New LockDisposer(Sub()
ExitWriteLock()
End Sub)
End Function