1. What is a String Type?
When using characters, use the String type. Enclose the value of the variable in "" (double quotes).
2. String Processing Operations
Here are some representative operations commonly used with the String type.
Operations:
Note: Character positions start from 0. For "abc", a is at position 0, b is at position 1, and c is at position 2.
1. Combine Strings
Combine strings into a single string.
Message Box Input Example:
Output Example:
2. Replacing Characters
Replace specified characters in the target string.
Example: "abc".Replace("abc","xyz")
Message Box Input Example:
Output Example:
3. Deleting Part of a String
Delete characters from the specified position in the target string.
Example: "abc".Remove(1,2)
Message Box Input Example:
Output Example:
4. Getting Character from a String
Get a character from the specified position in the target string.
Example: "abc".Chars(0)
Message Box Input Example:
Output Example:
5. Extracting a Substring
Get a substring from the specified position in the target string.
Example: "abc".Substring(0,2)
Message Box Input Example:
Output Example:
6. Trimming White Spaces from Start and End of String
Remove leading and trailing whitespaces from the target string.
Example: " a bc ".Trim()
Message Box Input Example:
Output Example:
7. Getting the Length of a String
Get the length of the target string.
Example: "abc".Length.toString
Message Box Input Example:
Output Example:
8. Splitting a String
Split the target string by the specified delimiter.
Example: "apple,peach,melon".Split(",".ToCharArray)
For Each (Collection of Each Element) & Message Box Input Example:
Output Example:
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article