' Declare a string variable and assign the value it it. Dim myLine As String = "dotnetspider.com is the best technology site"
Dim str as String
' extract portion of the string - starting from position 0, get 16 characters. str = myLine.Substring(0, 16) Console.WriteLine(str) ' Displays : dotnetspider.com
' extract portion of the string - starting from position 17, get 12 characters. str = myLine.Substring(17, 12) Console.WriteLine(str) ' Displays : is the best
' Split the line into words. Split based on the space (""). Dim strArray As String() = myLine.Split(" ") Console.WriteLine("strArray has " & strArray.Length & " words") ' Displays : strArray has 6 words
' Convert all characters to UPPERCASE str = myLine.ToUpper() Console.WriteLine(str) ' Displays : DOTNETSPIDER.COM IS THE BEST TECHNOLOGY SITE
' Find location of a word in a string Dim position As Int16 = myLine.IndexOf("best") Console.WriteLine(position) ' Displays : 24
' Insert a string into another string in specific position str = myLine.Insert(20, "one of ") Console.WriteLine(str) ' Displays : dotnetspider.com is one of the best technology site
|
No responses found. Be the first to respond and make money from revenue sharing program.
|