I need to use the substring function as I use it in the following example with a string :
Dim Campos As String
campos = "esto es un texto de ejemplo"
Campos = Campos.Substring(0, Campos.Length - 1)
But using it with the StringBuilder in the same way throws me an error. Does anyone know how to handle the function in another way with the StringBuilder
Dim Campos As StringBuilder
campos.AppendLine("esto es un texto de ejemplo")
Campos.Substring(0, Campos.Length - 1)
StringBuilder does not have a function
SubString
as it is not intended to replace (or improve upon) the methods ofString
. But it does have an overhead when initializing it.Applied to your example:
If you are not convinced, it is better to apply the
subString
before or after useStringBuilder
.It gives you an error because you are calling the string from the stringbuilder wrong.
You have to change:
For this:
Cheers!