Skip to content

Instantly share code, notes, and snippets.

@djordjedjukic
Last active December 15, 2017 10:08
Show Gist options
  • Save djordjedjukic/7e4b1fe92d89ce304c16f403127dc044 to your computer and use it in GitHub Desktop.
Save djordjedjukic/7e4b1fe92d89ce304c16f403127dc044 to your computer and use it in GitHub Desktop.
Extension methods
public static int Int(this string stringValue, int defaultValue = 0)
{
if (stringValue == null) return defaultValue;
int integer = Int32.TryParse(stringValue, out integer) ? integer : defaultValue;
return integer;
}
public static string ToLowerSafe(this string input)
{
return String.IsNullOrEmpty(input) ? input : input.ToLower();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment