title: Keyword 'void' cannot be used in this context when trying to declare a Func<void>
body: <p>Let's assume I have the following method:</p>
  
  <pre><code>private TResult CallWithSuccessHandler&lt;TResult&gt;(Func&lt;TResult&gt; func, System.Action onSuccess = null, System.Action onFailure = null)
  {
      try
      {
          var result = func();
          if (onSuccess != null) onSuccess();
          return result;
      }
      catch (Exception ex)
      {
          if (onFailure != null) onFailure();
          throw;
      }
  }
  </code></pre>
  
  <p>I can invoke this method like this:</p>
  
  <pre><code>var simpleFunc = new Func&lt;int&gt;(() =&gt; { return 1; });
  var result = CallWithSuccessHandler(simpleFunc, null, null);
  </code></pre>
  
  <p>This compiles without any problems in visual Studio and works fine.</p>
  
  <p>However, what I can't figure out is how I can invoke the CallwithSucessHandler method with a "Func" that does not return anything. In other words, I need 'func' to return "void".</p>
  
  <p>I attempted the following:</p>
  
  <pre><code>var voidFunc = new Func&lt;void&gt;(() =&gt; { return; });
  CallWithSuccessHandler(voidFunc, null, null);
  </code></pre>
  
  <p>but Visual Studio refuses to compile and displays the following error message:</p>
  
  <pre><code>"Keyword 'void' cannot be used in this context"
  </code></pre>
  
  <p>Specifically, Visual Studio does not like "new Func &lt; void >".</p>
  
  <p>What would be the proper syntax for a Func that returns "nothing"?</p>