title: Use the type double as an argument in C#
body: <p>Consider the following extension to a WPF <code>TextBox</code>:</p>
  <pre><code>public static void Parse&lt;T&gt;(this TextBox textBox, Func&lt;string, T&gt; parser)
  {
      try
      {
          T value = parser(textBox.Text);
          textBox.Text = value.ToString();
      }
      catch
      {
          textBox.Text = default(T).ToString();
      }
  }
  </code></pre>
  <p>That can be used like so:</p>
  <pre><code>private void TextBox_LostFocus(object sender, RoutedEventArgs e)
  {
      ((TextBox)sender).Parse(double.Parse);
  }
  </code></pre>
  <p>My question is: can the extension method be updated/modified so that I can call <code>((TextBox)sender).Parse(double)</code> instead of <code>((TextBox)sender).Parse(double.Parse)</code>?</p>
  <hr />
  <p><strong>EDIT</strong></p>
  <p>The extension method is meant to be very easily used to make sure that the user set, for example, a <code>double</code> or <code>int</code> value inside a <code>TextBox</code>. The idea is to use the method like so:</p>
  <pre><code>private void TextBox_LostFocus(object sender, RoutedEventArgs e)
  {
      ((TextBox)sender).Parse(double); // make sure the input is a double
      //or
      ((TextBox)sender).Parse(int); // make sure the input is a int
  }
  </code></pre>
  <p>What goes inside the extension method doesn't really matter, as long as it works, but I want a minimalist code.</p>
  <p>Perhaps a better name for the method would be something like <code>ParseTo()</code>, or better yet, <code>Validate()</code>, as said in the comments.</p>