Last active
December 15, 2015 13:59
-
-
Save spetryjohnson/5271045 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 { | |
/// <summary> | |
/// Null safe value of .Trim(). If the value is null, returns an empty string. | |
/// </summary> | |
public static string TrimNullSafe(this string value) { | |
return (value != null) | |
? value.Trim() | |
: String.Empty; | |
} | |
} | |
var upcCode = UPCCode.Text.TrimNullSafe(); | |
if (!String.IsNullOrEmpty(upcCode)) { | |
// update db | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment