Created
January 6, 2012 13:47
-
-
Save clausjoergensen/1570687 to your computer and use it in GitHub Desktop.
This file contains 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 class StringExtensions | |
{ | |
public static bool TryParseInt16(this string source, Func<short, bool> condition) | |
{ | |
short result = 0; | |
if (short.TryParse(source, out result)) | |
return condition(result); | |
else | |
return false; | |
} | |
public static bool TryParseInt32(this string source, Func<int, bool> condition) | |
{ | |
int result = 0; | |
if (int.TryParse(source, out result)) | |
return condition(result); | |
else | |
return false; | |
} | |
public static bool TryParseDouble(this string source, Func<double, bool> condition) | |
{ | |
double result = 0; | |
if (double.TryParse(source, out result)) | |
return condition(result); | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment