Skip to content

Instantly share code, notes, and snippets.

@fbstj
Created March 23, 2012 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbstj/2171203 to your computer and use it in GitHub Desktop.
Save fbstj/2171203 to your computer and use it in GitHub Desktop.
some extension methods for Control
public static int Value(this Control _, NumberStyles s, IFormatProvider p)
{
int d;
if (int.TryParse(_.Text, s, p, out d))
return d;
return 0;
}
public static double Value(this Control _)
{
double d;
if (double.TryParse(_.Text, out d))
return d;
return 0;
}
public static T[] Value<T>(this Control _, Converter<Control, T[]> converter) { return converter(_); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment