I want to add my own member to the StringBuilder class, but when I go to create it IntelliSense doesn't bring it up.
public class myStringBuilder()
Inherits System.Text.[StringBuilder should be here]
....
end class
Is it even possible? thanks
In visual basic, StringBuilder is a class and it is useful to represent a mutable string of characters and it is an object of System. Text namespace. Like string in vb, we can use StringBuilder to create variables to hold any kind of text which is a sequential collection of characters based on our requirements.
Both String and StringBuilder are reference type.
StringBuilder is sealed because it assembles strings, e.g. there should never be a reason to inherit from it because any use should be limited in scope. StringBuilder is not a replacement for string and should never be used that way.
The main difference is StringBuilder is Mutable whereas String is Immutable. String is immutable, Immutable means if you create string object then you cannot modify it and It always create new object of string type in memory. On the other hand, StringBuilder is mutable.
StringBuilder
is NotInheritable
(aka sealed
in C#) so you cannot derive from it. You could try wrapping StringBuilder
in your own class or consider using extension methods instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With