Sic.Framework/Sicentury.Core/Extensions/StringExtension.cs

13 lines
372 B
C#

#nullable enable
namespace Sicentury.Core.Extensions
{
public static class StringExtension
{
public static string? Truncate(this string? value, int maxLength, string truncationSuffix = "…")
{
return value?.Length > maxLength
? value.Substring(0, maxLength) + truncationSuffix
: value;
}
}
}