String IndexOf and Insert : String Search « Data Types « VB.Net






String IndexOf and Insert

String IndexOf and Insert
   
Imports System
Imports System.Collections
 
Public Class MainClass

    Shared Sub Main(ByVal args As String())
             Dim s1 As String = "abcd"
             Dim s2 As String = "ABCD"
             Dim s3 As String = "S3"
             s3 = s3 & "Tail"


             Dim s5 As String = String.Copy(s2) '
             Console.WriteLine("s5 copied from s2: {0}", s5)


             Console.WriteLine("String s3 is {0} characters long. ", _
                s5.Length)

             Console.WriteLine( )
             Console.WriteLine("s3: {0}", s3)

             Console.WriteLine("s3: ends with 3?: {0}", s3.EndsWith("3"))

             Console.WriteLine( )

             Console.Write("The first occurrence of 3 ")
             Console.WriteLine("in s3 is {0}", s3.IndexOf("3"))


             Dim location As Integer = s3.IndexOf("3")


             Dim s10 As String = s3.Insert(location, "3")
             Console.WriteLine("s10: {0}", s10)


             Console.WriteLine( )
    End Sub

End Class

           
         
    
    
  








Related examples in the same category

1.Combine Insert and IndexOfCombine Insert and IndexOf
2.Using String searching methods: IndexOfUsing String searching methods: IndexOf
3.LastIndexOf to find a character in a stringLastIndexOf to find a character in a string
4.IndexOf to locate a substring in a stringIndexOf to locate a substring in a string
5.LastIndexOf to find a substring in a stringLastIndexOf to find a substring in a string
6.IndexOfAny to find first occurrence of character in arrayIndexOfAny to find first occurrence of character in array
7.LastIndexOfAny to find first occurrence of character in arrayLastIndexOfAny to find first occurrence of character in array
8.String: Substring, LastIndexOfString: Substring, LastIndexOf
9.String IndexOf and Insert at a positionString IndexOf and Insert at a position
10.Sample for String.LastIndexOfAny(Char[])
11.Search string with IndexOf
12.String.LastIndexOfAny Method (Char[])