c.StringExtension.Left

PHOTO EMBED

Sun Sep 19 2021 19:33:14 GMT+0000 (Coordinated Universal Time)

Saved by @rick_m #c#

public static class StringExtensions
{
    public static string Left(this string value, int maxLength)
    {
        if (string.IsNullOrEmpty(value)) return value;
        maxLength = Math.Abs(maxLength);

        return ( value.Length <= maxLength 
               ? value 
               : value.Substring(0, maxLength)
               );
    }
}
content_copyCOPY

string left = s.Left(number);

https://stackoverflow.com/questions/7574606/left-function-in-c-sharp