Check if Strings Contains Replacing Sub Strings in VB.Net

0
755

This Tutorial is all about Check if Strings Contains Replacing Sub Strings in VB.Net. In this tutorial you will learn about Check if Strings Contains Replacing Sub Strings in VB.Net. So lets get Started:

  • String.Contains is a method used when you want to check whether a specified sub string occurs within the string. It returns True if the value parameter occurs within the string, otherwise it returns False.
  • The String.Replace is a method used when you want to replace all occurrences of a specified string with another specified string.It returns new string that is same as the current string except that all instances of old Value are replaced with new Value. If oldValue is not found this method returns the same string unchanged.
  • Try this code:
    1. Dim OriginalString As String = "Hello User"
    2. Dim ModifiedString As String = String.Empty;
    3. If OriginalString.Contains("Hello") Then
    4. ModifiedString = OriginalString.Replace("Hello", "Good Bye")
    5. Console.WriteLine(ModifiedString) ' = Good Bye User"
    6. End If

If you have any comments or suggestions about on Check if Strings Contains Replacing Sub Strings in VB.Net, please feel free to contact our webpage.

Other Articles Readers might read:

 

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here