首页 > 解决方案 > Convert c# code with inline delegate to vb.net

问题描述

I need to convert this code to vb.net

public IDisposable WriteLock()
{
    EnterWriteLock();
    return new LockDisposer(delegate() { ExitWriteLock(); });
}

This is what I got with the online converters

Public Function WriteLock() As IDisposable
    EnterWriteLock()
    Return New LockDisposer(Sub() ExitWriteLock()) <-- Error Line
End Function

I am using .net 2.0

标签: c#vb.netdelegates

解决方案


Public Function WriteLock() As IDisposable
     EnterWriteLock()
     Return New LockDisposer(AddressOf ExitWriteLock)
End Function

推荐阅读