本文整理汇总了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