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

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

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

    Public Sub Main()

        Dim chA As Char
        chA = "A"c
        Dim ch1 As Char
        ch1 = "1"c
        Dim str As String
        str = "test string"

        Console.WriteLine(chA.CompareTo("B"c))          ' Output: "-1" (meaning 'A' is 1 less than 'B')
        Console.WriteLine(chA.Equals("A"c))             ' Output: "True"
        Console.WriteLine(Char.GetNumericValue(ch1))    ' Output: "1"
        Console.WriteLine(Char.IsControl(Chr(9)))       ' Output: "True"
        Console.WriteLine(Char.IsDigit(ch1))            ' Output: "True"
        Console.WriteLine(Char.IsLetter(","c))          ' Output: "False"
        Console.WriteLine(Char.IsLower("u"c))           ' Output: "True"
        Console.WriteLine(Char.IsNumber(ch1))           ' Output: "True"
        Console.WriteLine(Char.IsPunctuation("."c))     ' Output: "True"
        Console.WriteLine(Char.IsSeparator(str, 4))     ' Output: "True"
        Console.WriteLine(Char.IsSymbol("+"c))          ' Output: "True"
        Console.WriteLine(Char.IsWhiteSpace(str, 4))    ' Output: "True"
        Console.WriteLine(Char.Parse("S"))              ' Output: "S"
        Console.WriteLine(Char.ToLower("M"c))           ' Output: "m"
        Console.WriteLine("x"c.ToString())              ' Output: "x"

    End Sub

End Module

作者:VB.NET开发    项目:Syste   
' 导入命名空间
Imports System.IO

Module Example
   Public Sub Main()
      Dim sw As New StreamWriter("chars1.txt")
      Dim chars() As Char = { ChrW(&h0061), ChrW(&h0308) }
      Dim strng As New String(chars)
      sw.WriteLine(strng) 
      sw.Close()
   End Sub
End Module

作者:VB.NET开发    项目:Syste   
' 导入命名空间
Imports System.IO

Module Example
   Public Sub Main()
      Dim sw As New StreamWriter(".\chars2.txt")
      Dim utf32 As Integer = &h1D160
      Dim surrogate As String = Char.ConvertFromUtf32(utf32)
      sw.WriteLine("U+{0:X6} UTF-32 = {1} ({2}) UTF-16", 
                   utf32, surrogate, ShowCodePoints(surrogate))
      sw.Close()                    
   End Sub

   Private Function ShowCodePoints(value As String) As String
      Dim retval As String = Nothing
      For Each ch In value
         retval += String.Format("U+{0:X4} ", Convert.ToUInt16(ch))
      Next
      Return retval.Trim()
   End Function
End Module

作者:VB.NET开发    项目:Syste   
' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      ' Define a string with a variety of character categories.
      Dim s As String = "The car drove down the narrow, secluded road."
      ' Determine the category of each character.
      For Each ch In s
         Console.WriteLine("'{0}': {1}", ch, Char.GetUnicodeCategory(ch)) 
      Next
   End Sub
End Module

作者:VB.NET开发    项目:Syste   
Module Example
   Public Sub Main()
      Dim result As String = String.Empty
      For ctr As Integer = &h10107 To &h10110     ' Range of Aegean numbers.
         result += Char.ConvertFromUtf32(ctr)
      Next         
      Console.WriteLine("The string contains {0} characters.", result.Length) 
   End Sub
End Module

作者:VB.NET开发    项目:Syste   
' 导入命名空间
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim result As String = String.Empty
      For ctr As Integer = &h10107 To &h10110     ' Range of Aegean numbers.
         result += Char.ConvertFromUtf32(ctr)
      Next         
      Dim si As New StringInfo(result)
      Console.WriteLine("The string contains {0} characters.", si.LengthInTextElements) 
   End Sub
End Module

作者:VB.NET开发    项目:Syste   
Module Example
   Public Sub Main()
      Dim combining As String = ChrW(&h0061) + ChrW(&h0308)
      ShowString(combining)
      
      Dim normalized As String = combining.Normalize()
      ShowString(normalized)
   End Sub
   
   Private Sub ShowString(s As String)
      Console.Write("Length of string: {0} (", s.Length)
      For ctr As Integer = 0 To s.Length - 1
         Console.Write("U+{0:X4}", Convert.ToUInt16(s(ctr)))
         If ctr <> s.Length - 1 Then Console.Write(" ")
      Next 
      Console.WriteLine(")")
      Console.WriteLine()
   End Sub
End Module


问题


面经


文章

微信
公众号

扫码关注公众号