StringExtensionsFirst Method (String, Int32, Char) |
Gets the first n characters of the string. The returned string always will be exactly
the specified length, and never null. The original string may be null or empty.
If the original string is null, empty, or shorter than requested, the returned string will be right-padded with the pad charcter.
If the original string is longer than requested, the returned string will be truncated to the requested length.
Namespace:
NetQuarry
Assembly:
EAP.Core (in EAP.Core.dll) Version: 2.0.0.0 (4.6.8.0)
Syntax public static string First(
this string s,
int n,
char pad
)
<ExtensionAttribute>
Public Shared Function First (
s As String,
n As Integer,
pad As Char
) As String
Parameters
- s
- Type: SystemString
The original string. - n
- Type: SystemInt32
The number of characters to return. - pad
- Type: SystemChar
The character with which to right-pad the result if the original string is shorter than the requested length.
Return Value
Type:
StringThe first n characters of the original string, padded as necessary.
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