Created
February 13, 2015 21:56
-
-
Save kpespisa/21c31c712ace6d7c19e0 to your computer and use it in GitHub Desktop.
ToSafeString() extension method to get an object's string representation or the empty string if the object is null
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 string ToSafeString(this object obj) | |
{ | |
if (obj == null) | |
{ | |
return string.Empty; | |
} | |
return obj.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment