public static string TruncateLeft(this string instance, int truncateToLength, bool useEllipses = false)
{
if (string.IsNullOrWhiteSpace(instance))
{
return string.Empty;
}
if (instance.Length <= truncateToLength)
{
return instance;
}
if (useEllipses)
{
return "…" + instance.Substring(instance.Length - truncateToLength + 1, truncateToLength - 1);
}
return instance.Substring(instance.Length - truncateToLength, truncateToLength);
}
}