I have a repeater that displays data from my Projects table. There are projectId, name and description. I use Substring(1, 240) on description. But sometimes the string is s
Based on Jon Skeet's answer, I think it should be checking for null or else it's not exactly a safe method :)
public static string SafeSubstring(this string text, int start, int length)
{
if (text == null) return null;
return text.Length <= start ? ""
: text.Length - start <= length ? text.Substring(start)
: text.Substring(start, length);
}