From the course: Visual Basic Essential Training
Unlock this course with a free trial
Join today to access over 24,500 courses taught by industry experts.
Modify string contents - Visual Basic Tutorial
From the course: Visual Basic Essential Training
Modify string contents
- [Instructor] Modifying the contents of a string involves using various methods provided by the string class to alter, replace or format strings. We'll look at how to trim a string, change the string case and replace parts of the string. But before we do that, we're saying we're modifying the contents, but remember, strings are immutable. So let's talk about that first. Let's look at line 95. I'm declaring a variable called letters with spaces. Then I'm assigning a string literal, and you can see there are some spaces at the beginning and ending of the string. My goal is to run this trim method, which will remove the spaces at the beginning and end of the string. There's also a trim end, which only removes items from the end of the string, and there's a trim start that only removes items from the start of the string. So what's happening here is it's running this operation and it's assigning the results of that to this variable. Looks like we're modifying it, but what's happening…
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Understanding strings6m 41s
-
(Locked)
Create string variables4m
-
(Locked)
Concatenation and interpolation2m 56s
-
(Locked)
Search string contents2m 59s
-
(Locked)
Modify string contents3m 3s
-
(Locked)
String creation with StringBuilder5m 39s
-
(Locked)
Compare and equals5m 51s
-
(Locked)
Convert and format numbers to strings8m 4s
-
(Locked)
Implicit covert strings to numbers2m 50s
-
(Locked)
Use Parse and TryParse conversions5m 4s
-
(Locked)
-
-
-
-
-
-
-
-
-
-
-