Click or drag to resize

StringExtensionsTruncate Method

Truncates a string value to a maximum length. If the length of the string value is already less or equal to maxLength the original string value is returned.

Namespace:  Enkoni.Framework
Assembly:  Enkoni.Framework (in Enkoni.Framework.dll) Version: 1.3.0.1
Syntax
public static string Truncate(
	this string source,
	int maxLength
)

Parameters

source
Type: SystemString
The string value that must be truncated.
maxLength
Type: SystemInt32
The maximum length of the returned string.

Return Value

Type: String
The string value truncated to the specified length or the original string if the length is already less then or equal to the maximum length.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
See Also