MCPcopy Create free account
hub / github.com/aptabase/aptabase / Truncate

Method Truncate

src/Extensions/StringExtensions.cs:5–14  ·  view source on GitHub ↗
(this string value, int maxLength, string suffix = "...")

Source from the content-addressed store, hash-verified

3public static class StringExtensions
4{
5 public static string Truncate(this string value, int maxLength, string suffix = "...")
6 {
7 if (string.IsNullOrEmpty(value))
8 return value;
9
10 if (value.Length <= maxLength)
11 return value;
12
13 return $"{value[..(maxLength - suffix.Length)]}{suffix}";
14 }
15}

Callers 1

SplitPropsMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected