title: Enforce type of expression delegate at compile time
body: <p>I want to make a method that takes a <code>MemberExpression</code> and does something with it. At the moment I can do</p>
  <pre><code>private string myfunction&lt;T&gt;(Expression&lt;Func&lt;T&gt;&gt; exp)
  {
      if (exp.Body is MemberExpression member)
      {
          // do stuff
          return &quot;a string&quot;;
      }
      throw new Exception(&quot;wrong expression type&quot;);
  }
  </code></pre>
  <p>However, I'd like this method to have compile-time type safety. Is there any way to <em>require</em> that the delegate passed in is a <code>MemberExpression</code>? I was thinking something like</p>
  <pre><code>private string myfunction(LambdaExpression&lt;MemberExpression&gt; exp) 
  </code></pre>
  <p>However this obviously doesn't work because <code>LambdaExpression</code> isn't a generic type</p>
  <p>Any ideas on how to ensure this? Or do I just rely on the runtime exception?</p>