title: Modify ValueType from extension method?
body: <p>A few days ago I needed to toggle a <code>bool</code>, and I ended up doing like so:</p>
  
  <pre><code>IsVisible = !IsVisible;
  </code></pre>
  
  <p>I found that to be the simplest way to archive that functionality. But before doing like the example above, I tried out some different ways.</p>
  
  <p>Mostly about using a extension method. Which in my opinion would make it even simpler, or at least less chars to write.</p>
  
  <pre><code>IsVisible.toggle();
  </code></pre>
  
  <p>But as a <code>boolean</code> is a value type, the <code>bool</code> that is sent though to the extension method is a copy of the original <code>bool</code>, and not a reference type.</p>
  
  <pre><code>public static void Toggle(this boolean value)
  {
      value = !value;
  }
  </code></pre>
  
  <p>Which would do what I needed, but as the <code>boolean</code> getting toggled is a copy of the original <code>boolean</code> the change isn't applied to the original...</p>
  
  <p>I tried putting the ref keyword in front of <code>boolean</code>, but that didn't compile.
  And I still haven't found a reason for that not compiling, wouldn't that be the perfect functionality for extension methods?</p>
  
  <pre><code>public static void Toggle(this ref boolean value)
  </code></pre>
  
  <p>I even tried casting the <code>boolean</code> into a object, which in my head would make it into a reference type, and then it would no longer be a copy and the change would get passed back. That didn't work either.</p>
  
  <p>So my question is if it's possible to make a extension pass back changes, or another way to make it even simpler than it already is?</p>
  
  <p>I know it quite possible won't get any simpler or more logical than the top example, but you never know :)</p>