本文整理匯總了VB.NET中System.String.Length屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET String.Length屬性的具體用法?VB.NET String.Length怎麽用?VB.NET String.Length使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.String
的用法示例。
在下文中一共展示了String.Length屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Sample
Class Sample
Public Shared Sub Main()
Dim str As String = "abcdefg"
Console.WriteLine("1) The length of '{0}' is {1}", str, str.Length)
Console.WriteLine("2) The length of '{0}' is {1}", "xyz", "xyz".Length)
Dim length As Integer = str.Length
Console.WriteLine("1) The length of '{0}' is {1}", str, length)
End Sub
End Class
輸出:
1) The length of 'abcdefg' is 7 2) The length of 'xyz' is 3 3) The length of 'abcdefg' is 7
示例2: Example
' 導入命名空間
Imports System.Text
Module Example
Public Sub Main()
Dim characters As String = "abc" + ChrW(0) + "def"
Console.WriteLine(characters.Length) ' Displays 7
End Sub
End Module