Created
March 23, 2012 14:32
-
-
Save fbstj/2171203 to your computer and use it in GitHub Desktop.
some extension methods for Control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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