title: C#, How to delete copy-pase with handlers
body: <p>Please say about "How optimally" rewrite this code without copy-paste.
  Now I have two handlers with equivalent lambda handlers...
  Sorry for more code and bad style ((</p>
  
  <pre><code>    wc.DownloadStringCompleted += (sender, args) =&gt;
      {
          try
          {
              res = (T)(object)args.Result;
              var cook = Regex.Matches(wc.ResponseHeaders.ToString(), "Set\\-Cookie:\\s*([\\w\\-_\\.]+\\s*=\\s*[^;]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline);
              foreach (Match val in cook)
                  cookies += val.Groups[1].Value.Trim() + "; ";
              isComplited = true;
          }
          catch (Exception e)
          {
              lastError = e.InnerException.Message;
          }
      };
  
  
      wc.UploadDataCompleted += (sender, args) =&gt;
      {
          try
          {
              res = (T)(object)args.Result;
              var cook = Regex.Matches(wc.ResponseHeaders.ToString(), "Set\\-Cookie:\\s*([\\w\\-_\\.]+\\s*=\\s*[^;]+)", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline);
              foreach (Match val in cook)
                  cookies += val.Groups[1].Value.Trim() + "; ";
              isComplited = true;
          }
          catch (Exception e)
          {
              lastError = e.InnerException.Message;
          }
      };
  </code></pre>