title: How do I translate this C# lambda into VB.net?
body: <p>I'm having difficulty translating a C# statement into VB.  I don't know if this is a lambda, which I do use but I'm not that expert with, or a separator, which I understand even less.  According to Microsoft, the C# <a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/lambda-operator" rel="nofollow noreferrer">'=>' symbol</a> can be used in those 2 different ways.</p>
  
  <p>The line of C# code I'm having trouble with is:</p>
  
  <pre><code>RecurringJob.AddOrUpdate(() =&gt; TextBuffer.WriteLine("text"), Cron.Minutely);
  </code></pre>
  
  <p>It is from the Startup.cs file in the <a href="https://github.com/HangfireIO/Hangfire.Samples" rel="nofollow noreferrer">sample hangfire.mvcApplication project</a>.  This is the full Class:</p>
  
  <pre><code>public void Configuration(IAppBuilder app)
  {
      GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");
      app.UseHangfireDashboard();
      app.UseHangfireServer();
      RecurringJob.AddOrUpdate(
          () =&gt; TextBuffer.WriteLine("Recurring Job completed successfully!"), 
          Cron.Minutely);
  }
  
  the TextBuffer.WriteLine reference is:
  
  public static void WriteLine(string value)
  {
      lock (Buffer)
      {
          Buffer.AppendLine(String.Format("{0} {1}", DateTime.Now, value));
      }
  }
  </code></pre>
  
  <p>This is what I tried, which is not really accurate; I tried a lot of variations:</p>
  
  <pre><code>RecurringJob.AddOrUpdate(Function() TextBuffer.WriteLine("text"), Cron.Minutely)
  </code></pre>
  
  <p>And the syntax error I get in Visual Studio is:</p>
  
  <pre><code>Expression does not produce a value
  </code></pre>
  
  <p>I went to the definitions for AddOrUpdate and saw the following overloads, but I'm not sure which is the proper selection to use nor how the syntax would look once I pick the proper overload.</p>
  
  <pre><code>Public Shared Sub AddOrUpdate(methodCall As Expression(Of Action), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(methodCall As Expression(Of Action), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(methodCall As Expression(Of Func(Of Task)), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(methodCall As Expression(Of Func(Of Task)), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(recurringJobId As String, methodCall As Expression(Of Action), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(recurringJobId As String, methodCall As Expression(Of Action), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(recurringJobId As String, methodCall As Expression(Of Func(Of Task)), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(recurringJobId As String, methodCall As Expression(Of Func(Of Task)), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(methodCall As Expression(Of Action(Of T)), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(methodCall As Expression(Of Action(Of T)), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(methodCall As Expression(Of Func(Of T, Task)), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(methodCall As Expression(Of Func(Of T, Task)), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(recurringJobId As String, methodCall As Expression(Of Action(Of T)), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(recurringJobId As String, methodCall As Expression(Of Action(Of T)), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(recurringJobId As String, methodCall As Expression(Of Func(Of T, Task)), cronExpression As Func(Of String), Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  Public Shared Sub AddOrUpdate(Of T)(recurringJobId As String, methodCall As Expression(Of Func(Of T, Task)), cronExpression As String, Optional timeZone As TimeZoneInfo = Nothing, Optional queue As String = "default")
  </code></pre>
  
  <p>I just don't understand what the method is looking for or how to properly write it.</p>