Strings.LSet(String, Int32) 方法
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回靠左對齊的字串,其中包含調整為指定之長度的指定字串。
public:
static System::String ^ LSet(System::String ^ Source, int Length);
C#
public static string LSet (string? Source, int Length);
C#
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
式。
VB
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)
如果指定的字串長度超過指定的長度,則傳回的字串會縮短為指定的長度。 如果指定的字串比指定的長度短,則會將空格新增至傳回字串的右端,以產生適當的長度。
產品 | 版本 |
---|---|
.NET | Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |