当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET Char结构体代码示例

本文整理汇总了VB.NET中System.Char结构体的典型用法代码示例。如果您正苦于以下问题:VB.NET Char结构体的具体用法?VB.NET Char怎么用?VB.NET Char使用的例子?那么恭喜您, 这里精选的结构体代码示例或许可以为您提供帮助。


在下文中一共展示了Char结构体的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: CharStructure

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
开发者ID:VB.NET开发者,项目名称:System,代码行数:30,代码来源:Char

示例2: Example

' 导入命名空间
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
开发者ID:VB.NET开发者,项目名称:System,代码行数:12,代码来源:Char

输出:


示例3: Example

' 导入命名空间
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
开发者ID:VB.NET开发者,项目名称:System,代码行数:21,代码来源:Char

输出:

U+01D160 UTF-32 = ð (U+D834 U+DD60) UTF-16

示例4: Example

' 导入命名空间
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
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Char

输出:

T': UppercaseLetter
h': LowercaseLetter
e': LowercaseLetter
: SpaceSeparator
r': LowercaseLetter
e': LowercaseLetter
d': LowercaseLetter
: SpaceSeparator
c': LowercaseLetter
a': LowercaseLetter
r': LowercaseLetter
: SpaceSeparator
d': LowercaseLetter
r': LowercaseLetter
o': LowercaseLetter
v': LowercaseLetter
e': LowercaseLetter
: SpaceSeparator
d': LowercaseLetter
o': LowercaseLetter
w': LowercaseLetter
n': LowercaseLetter
: SpaceSeparator
t': LowercaseLetter
h': LowercaseLetter
e': LowercaseLetter
: SpaceSeparator
l': LowercaseLetter
o': LowercaseLetter
n': LowercaseLetter
g': LowercaseLetter
,': OtherPunctuation
: SpaceSeparator
n': LowercaseLetter
a': LowercaseLetter
r': LowercaseLetter
r': LowercaseLetter
o': LowercaseLetter
w': LowercaseLetter
,': OtherPunctuation
: SpaceSeparator
s': LowercaseLetter
e': LowercaseLetter
c': LowercaseLetter
l': LowercaseLetter
u': LowercaseLetter
d': LowercaseLetter
e': LowercaseLetter
d': LowercaseLetter
: SpaceSeparator
r': LowercaseLetter
o': LowercaseLetter
a': LowercaseLetter
d': LowercaseLetter
.': OtherPunctuation

示例5: Example

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
开发者ID:VB.NET开发者,项目名称:System,代码行数:9,代码来源:Char

输出:

The string contains 20 characters.

示例6: Example

' 导入命名空间
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
开发者ID:VB.NET开发者,项目名称:System,代码行数:13,代码来源:Char

输出:

The string contains 10 characters.

示例7: Main

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
开发者ID:VB.NET开发者,项目名称:System,代码行数:19,代码来源:Char

输出:

Length of string: 2 (U+0061 U+0308)

Length of string: 1 (U+00E4)


注:本文中的System.Char结构体示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。