Created
May 18, 2009 03:52
-
-
Save goodwill/113306 to your computer and use it in GitHub Desktop.
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 class StringUtil | |
{ | |
public static string NullDefault(this string value, string valueIfNull) | |
{ | |
if (string.IsNullOrEmpty(value)) | |
return valueIfNull; | |
else | |
return value; | |
} | |
public static bool IsNullOrDefault(this string value, string valueIfNull, bool ignoreCase) | |
{ | |
StringComparison compareParam=StringComparison.InvariantCulture; | |
if (ignoreCase) | |
compareParam=StringComparison.InvariantCultureIgnoreCase; | |
return String.Equals(NullDefault(value, valueIfNull), valueIfNull, compareParam); | |
} | |
public static bool IsNullOrDefault(this string value, string valueIfNull) | |
{ | |
return IsNullOrDefault(value, valueIfNull, true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment