Sitecore 5.0 API

StringUtil.Clip Method 

Clips a string at a certain length.

[Visual Basic]
Public Shared Function Clip( _
   ByVal text As String, _
   ByVal length As Integer, _
   ByVal ellipsis As Boolean _
) As String
[C#]
public static string Clip(
   string text,
   int length,
   bool ellipsis
);

Parameters

text
The text that will be clipped.
length
The maximum length of the returned string.
ellipsis
Indicates if the string should have en ellipsis (...) appended

Return Value

The clipped string.

Example

  string s0 = StringUtil.Clip("Hello world", 5, false); // "Hello"
  string s1 = StringUtil.Clip("Hello world", 5, true);  // "He..."

See Also

StringUtil Class | Sitecore Namespace