Truncate a String

Truncate a string with a specified Length

Truncate

The below method truncates a string to a given specified length

Package

Install-Package FC.Core.Extension -Version 5.0.1

Sample Code

[Theory]
[InlineData("This was the value to be truncted", 5)]
[InlineData("Truncated output", 10)]

public void TruncateTest_Test(string value, int length)
{
    string output = value.Truncate(length);            
    _output.WriteLine(output);
    output.ShouldNotBeEmpty();
}

Output

Last updated