Make immutable objects mutable

In .Net the String object is an immutable object, which means that it’s basically constant and can’t be changed. You can’t change a string, you can only create new strings. The various methods that the String class have never directly change the string they operate on, instead they return a new string. Dim myString As String = "Hello World" Dim mySecondString As String = myString.Substring(0, 5) Console.WriteLine(myString) ‘Hello World Console.WriteLine(mySecondString) ‘Hello Even though we developers modify strings all the time, which can make them look mutable, they aren’t. What happens is that a new string is created and the reference … Continue reading Make immutable objects mutable