title: Convert c# code with inline delegate to vb.net
body: <p>I need to convert this code to vb.net</p>
  
  <pre><code>public IDisposable WriteLock()
  {
      EnterWriteLock();
      return new LockDisposer(delegate() { ExitWriteLock(); });
  }
  </code></pre>
  
  <p>This is what I got with the online converters</p>
  
  <pre class="lang-vb prettyprint-override"><code>Public Function WriteLock() As IDisposable
      EnterWriteLock()
      Return New LockDisposer(Sub() ExitWriteLock()) &lt;-- Error Line
  End Function
  </code></pre>
  
  <p>I am using .net 2.0</p>