Click or drag to resize

StringExtensionsFirst Method (String, Int32)

Gets the first n characters of the string. The returned string always will be the specified length or shorter, and never null. The original string may be null or empty. If the original string is null or shorter than requested, the returned string will be returned (or string.Empty if null). 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
)

Parameters

s
Type: SystemString
The original string.
n
Type: SystemInt32
The number of characters to return.

Return Value

Type: String
The original string, truncated to n characters if 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