Here is code you can use to truncate string :

 

 

public static string Truncate( string value, int maxLength )
 {
 return value.Length <= maxLength ? value : value.Substring(0, maxLength); 
 }

 

 

 

// Exmple:
var testString = "This is Test...!!!";
testString = testString.Truncate( 12 );
// Output-->'This is Test'

testString = testString.Truncate( 100 );
// Output-->'This is Test...!!!'