Manipulating Strings

  • myString = "Thank God It‘s Monday" [sets the value of a string]
  • "Eric said: ""That‘s a great car!""" [escape double quotes by two pairs of double quotes]
  • mySpecialChar = myString(2) [accesses a specific character within a string; returns: a]
  • myIndex = myString.IndexOf("God") [retrieves the starting index of the string; returns: 6]
  • mySubstring = myString.Substring(6, 3) [retrieves a substring by specifying starting index & length; returns: God]
  • myReplacedString = myString.Replace("Monday", "Friday") [replaces the first input parameter with the second; returns: Thank God It‘s Friday]
  • myTrimmedString = myString.Trim() [removes white spaces at the beginning & end of a string]
  • myStringLowerCase = myString.ToLower() [changes all characters to lower case letters; returns: thank god it‘s monday]
  • myStringUpperCase = myString.ToUpper() [changes all characters to upper case letters; returns: THANK GOD IT’S MONDAY]
Was this article helpful?
0 out of 0 found this helpful