Strings.LSet(String, Int32) 方法

定义

返回一个左对齐的字符串,该字符串包含调整为指定长度的指定字符串。

public:
 static System::String ^ LSet(System::String ^ Source, int Length);
public static string LSet(string? Source, int Length);
public static string LSet(string Source, int Length);
static member LSet : string * int -> string
Public Function LSet (Source As String, Length As Integer) As String

参数

Source
String

必填。 String 表达式。 字符串变量的名称。

Length
Int32

必填。 Integer 表达式。 返回的字符串的长度。

返回

一个左对齐的字符串,包含调整为指定长度的指定字符串。

示例

此示例演示函数 LSet 的使用。

Dim testString As String = "Left"
Dim lString As String
' Returns "Left      "
lString = LSet(testString, 10)
' Returns "Le"
lString = LSet(testString, 2)
' Returns "Left"
lString = LSet(testString, 4)

注解

如果指定的字符串长度超过指定的长度,则返回的字符串将缩短为指定的长度。 如果指定的字符串比指定的长度短,则返回的字符串的右端添加空格以生成适当的长度。

适用于

另请参阅