vb System.Char.IsWhiteSpace类(方法)实例源码

下面列出了vb System.Char.IsWhiteSpace 类(方法)源码代码实例,从而了解它的用法。

作者:VB.NET开发    项目:Syste   
Module IsWhiteSpaceSample

    Sub Main()

        Dim str As String
        str = "black matter"

        Console.WriteLine(Char.IsWhiteSpace("A"c))      ' Output: "False"
        Console.WriteLine(Char.IsWhiteSpace(str, 5))    ' Output: "True"

    End Sub

End Module

作者:VB程序    项目:Syste   
Public Class Tester
    Public Shared Sub Main
        Dim source As String = _
            Space(17) & "This    string    had " & Chr(12) & _
            StrDup(5, Chr(9)) & "extra whitespace. " & Space(27)
        Dim thisIsWhiteSpace As Boolean
        Dim prevIsWhiteSpace As Boolean
        Dim result As New System.Text.StringBuilder(source.Length)
        Dim counter As Integer

        For counter = 0 To source.Length - 1
            prevIsWhiteSpace = thisIsWhiteSpace
            thisIsWhiteSpace = Char.IsWhiteSpace(source.Chars(counter))
            If (thisIsWhiteSpace = False) Then
                If (prevIsWhiteSpace = True) AndAlso _
                   (result.Length > 0) Then result.Append(Space(1))
                result.Append(source.Chars(counter))
            End If
        Next counter
        Console.WriteLine(result.ToString())
    End Sub


End Class


问题


面经


文章

微信
公众号

扫码关注公众号