Mega Code Archive

 
Categories / VB.Net / Data Types
 

String properties Length and Chars and method CopyTo of class String

Imports System Public Class MainClass    Shared Sub Main()       Dim string1 As String       Dim characterArray As Char()       Dim i As Integer       Dim quotes As Char = ChrW(34)       string1 = "hello there"       characterArray = New Char(5) {}       Console.WriteLine( "string1: " & quotes & string1 )       Console.WriteLine( " test Length property ")       Console.WriteLine( "Length of string1: " & string1.Length )       Console.WriteLine( " loop through characters in string1 and display reversed ")       Console.WriteLine( "The string reversed is: ")       For i = string1.Length - 1 To 0 Step -1          Console.WriteLine( string1.Chars(i) )       Next       Console.WriteLine( " copy characters from string1 into characterArray ")       string1.CopyTo(0, characterArray, 0, 5)       Console.WriteLine( "The character array is: " )       For i = 0 To characterArray.GetUpperBound(0)          Console.WriteLine( characterArray(i) )       Next    End Sub ' Main End Class