title: How can I provide the field to use in a function?
body: <p>Something working on the likes of Linq's OrderBy, in which you can specify the key with which it is supposed to do the ordering.</p>
  
  <p>To make things specific, in my case I have an equivalent of a struct with two bool properties, one .IsNice and another .IsPretty; I then want to be able to do a function returning wether an instance Is Pretty or Is Nice.</p>
  
  <p>I could make two functions,</p>
  
  <pre><code>    bool itIsPretty (ExampleStruct toVerify);
      bool itIsNice (ExampleStruct toVerify);
  </code></pre>
  
  <p>both, however, are essentially the same thing! Both are nothing more than a return toVerify.(IsPretty / IsNice), and I do not want to have a copy and pasted function.</p>
  
  <p>Another alternative would be making the following:</p>
  
  <pre><code>    bool isItNiceOrPretty (ExampleStruct toVerify, bool checkForNiceness)
      {
          if (checkForNiceness) return toVerify.IsNice;
          else return toVerify.IsPretty;
      }
  </code></pre>
  
  <p>But, what if there were more than these two types? Well, I could turn this bool parameter into an integer, or a string, but then I'd need to keep a table with all the key values and their respective fields... This has such a potential for mess and counter-intuitivity when I add and/or remove fields of the example struct that I don't even want to think any more about it.</p>
  
  <p>So, is there a way to do what I'm thinking, to create such a flexible function? Or do I have to stick to the dreadful Ctrl+C Ctrl+V?</p>