Skip to content

Instantly share code, notes, and snippets.

@clausjoergensen
Created January 6, 2012 13:47
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 clausjoergensen/1570687 to your computer and use it in GitHub Desktop.
Save clausjoergensen/1570687 to your computer and use it in GitHub Desktop.
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