Click or drag to resize

ExtensionsPadOrCut Method (String, UInt16, Position)

Shortens or extends a string to a specific length.

Namespace:  Cauldron
Assembly:  Cauldron (in Cauldron.dll) Version: 3.2.0.1 (3.2.0.1)
Syntax
C#
public static string PadOrCut(
	this string string,
	ushort newlength,
	Position position
)

Parameters

string
Type: SystemString
The string to shorten or extend.
newlength
Type: SystemUInt16
The new length of the string.
position
Type: CauldronPosition
Indicates on which position to modify the string.

Return Value

Type: String
A new string that is equivalent to this instance, but aligned to the left, right or center, depending on the position and padded or cropped on the left, right or both with as many paddingChar characters as needed to create a length of newlength. However, if newlength is equal to the length of this instance, the method returns a reference to the existing instance. If totalWidth is 0, the method returns Empty.

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).
Exceptions
ExceptionCondition
ArgumentNullExceptionstring is null.
See Also