title: .NET C++: How to bind parameters to a delegate to create a new a zero-parameter delegate?
body: <p>Is there any way to bind parameters to a delegate to create a new zero-parameter delegate?</p>
  
  <p>Something like:</p>
  
  <pre><code>delegate void FnDelegate(int id, String^ name);
  void Fn(int id, String^ name);
  
  Delegate^ del = &lt;some-function-name&gt;(gcnew FnDelegate(&amp;Fn), 1, "Name");
  </code></pre>
  
  <p>I notice that Form::Invoke probably uses some similar mechanism, so there MUST be some facility for this:</p>
  
  <pre><code>delegate void FnDelegate(int id, String^ name);
  Invoke(gcnew FnDelegate(&amp;Fn), 1, "Name");
  </code></pre>
  
  <p>Right now, I have to do something extremely awkward like this (for each function!):</p>
  
  <pre><code>void Fn(int id, String^ name);
  
  ref class FnWrapper
  {
  public:
     int     id;
     String^ name;
  
     void Execute()
     {
        Fn(id, name);
     }
  };
  
  delegate void VoidDelegate();
  Delegate^ CreateFnDelegate(int id, String^ name)
  {
     FnWrapper^ Wrapper = gcnew FnWrapper;
     Wrapper-&gt;id = id;
     Wrapper-&gt;name = name;
     return gcnew VoidDelegate(Wrapper, &amp;FnWrapper::Execute);
  }
  </code></pre>
  
  <p>There's got to be a more elegant way of doing this.</p>