Truncates a string if it's too long

Namespace: umbraco
Assembly:   umbraco (in umbraco)
Version: 1.0.2698.41384

Syntax

Visual Basic (Declaration)
Public Shared Function TruncateString ( _
	Text As String, _
	MaxLength As Integer, _
	AddString As String _
) As String
C#
public static string TruncateString (
	string Text,
	int MaxLength,
	string AddString
)
Visual C++
public:
static String^ TruncateString (
	String^ Text, 
	int MaxLength, 
	String^ AddString
)

Parameters

Text
System.String
The text to eventually truncate
MaxLength
System.Int32
The maximum number of characters (length)
AddString
System.String
String to append if text is truncated (ie "...")

Return Value

A truncated string if text if longer than MaxLength appended with the addString parameters. If text is shorter then MaxLength then the full - non-truncated - string is returned