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

13 lines
372 B
C#
Raw Permalink Normal View History

2026-06-15 10:56:30 +08:00
#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;
}
}
}