VB.Net by API/System/Char — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:51, 26 мая 2010
Содержание
Char.IsDigit
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("is digit: " & Char.IsDigit("aaa") )
End Sub " Main
End Class
Char.IsLetter
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("is letter: " & Char.IsLetter("aaa") )
End Sub " Main
End Class
Char.IsLetterOrDigit
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("is letter or digit: " & Char.IsLetterOrDigit("aaa") )
End Sub " Main
End Class
Char.IsLower
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("is lower case: " & Char.IsLower("aaa") )
End Sub " Main
End Class
Char.IsPunctuation
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("is punctuation: " & Char.IsPunctuation("aaa") )
End Sub " Main
End Class
Char.IsSymbol
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("is symbol: " & Char.IsSymbol("aaa"))
End Sub " Main
End Class
Char.IsUpper
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("is upper case: " & Char.IsUpper("aaa") )
End Sub " Main
End Class
Char.IsWhiteSpace
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
Char.ToLower
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("to lower case: " & Char.ToLower("aaa") )
End Sub " Main
End Class
Char.ToUpper
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("to upper case: " & Char.ToUpper("aaa") )
End Sub " Main
End Class