title: Passing a function to another function
body: <p>I am writing an HTTP wrapper class object in C# and I would like to give the main method the ability to receive a function as a parameter and then execute it on the source HTML returned by the POST/GET.</p>
  
  <p>For example I may want to pass a function that checks the headers for a cookie and only returns true if it's found OR pass a regular expression function that checks the source for a piece of content.</p>
  
  <p>I know in PHP or JS I could easily just pass functions as parameters but I am not sure on how to go about it without creating delegates that match the functions I want to use.</p>
  
  <p>I would like the code to be as "generic" as possible so that it could receive any function e.g Pseudocode would be like</p>
  
  <pre><code>public bool MakeHTTPRequest(string url, object possiblefunction)
  {
  
     make HTTP request
  
     if status == 200
     {
  
      string response = getresponse
  
      if(object is function){
  
          call object
      }
    }
  }
  </code></pre>
  
  <p>So the function may OR may NOT be passed in, or I may set a global property with it. Then I need to check IF a function exists and execute it if it does.</p>
  
  <p>The function could be ANYTHING and I want to future proof the code so it can handle any kind of function in the future that maybe passed to it.</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Thanks</p>