Skip to content

Instantly share code, notes, and snippets.

@kpespisa
Created February 13, 2015 21:56
Show Gist options
  • Save kpespisa/21c31c712ace6d7c19e0 to your computer and use it in GitHub Desktop.
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
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