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
Syntaxpublic static string Truncate(
this string source,
int maxLength
)
<ExtensionAttribute>
Public Shared Function Truncate (
source As String,
maxLength As Integer
) As String
public:
[ExtensionAttribute]
static String^ Truncate(
String^ source,
int maxLength
)
[<ExtensionAttribute>]
static member Truncate :
source : string *
maxLength : int -> string
Parameters
- source
- Type: SystemString
The string value that must be truncated. - maxLength
- Type: SystemInt32
The maximum length of the returned string.
Return Value
Type:
StringThe 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