本文整理匯總了VB.NET中System.String.PadLeft方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET String.PadLeft方法的具體用法?VB.NET String.PadLeft怎麽用?VB.NET String.PadLeft使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.String
的用法示例。
在下文中一共展示了String.PadLeft方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Public Class Example
Public Shared Sub Main()
Dim str As String
Dim pad As Char
str = "forty-two"
pad = "."c
Console.WriteLine(str.PadLeft(15, pad))
Console.WriteLine(str.PadLeft(2, pad))
End Sub
End Class
輸出:
......forty-two forty-two
示例2:
Dim str As String
str = "BBQ and Slaw"
Console.WriteLine(str.PadLeft(15)) ' Displays " BBQ and Slaw".
Console.WriteLine(str.PadLeft(5)) ' Displays "BBQ and Slaw".
示例3: String.PadLeft(Int length)
Public Class MainClass
Public Shared Sub Main()
'Strings
Dim strConstant As String = "ABC"
Dim strRepeat As New String("A"c, 20)
Dim strMyString As String = "Hello World"
Console.WriteLine(strMyString.PadLeft(30))
Console.WriteLine(strMyString.PadLeft(20, "."c))
End Sub
End Class