Sitecore 5.0 API

MainUtil.Substring Method (String, Int32, Boolean)

Gets a substring of maximum length of a string.

[Visual Basic]
Overloads Public Shared Function Substring( _
   ByVal _value As String, _
   ByVal max As Integer, _
   ByVal dots As Boolean _
) As String
[C#]
public static string Substring(
   string _value,
   int max,
   bool dots
);

Parameters

_value
A string.
max
The number of characters in the substring.
dots
If true, three dots are appended to the substring.

Return Value

A subtring starting at zero and ending a max characters of the string.

Remarks

No exception is thrown if max is greater than the length of the string.

Example

  string text = MainUtil.Substring("Hello world", 6, true); // "Hel..."
  string text = MainUtil.Substring("Hello world", 6, false); // "Hello "

See Also

MainUtil Class | Sitecore Namespace | MainUtil.Substring Overload List