6
I was trying to get blanks out of a string, but the .Trim()
does not work, it displays the white spaces yet:
var teste = texto.Trim();
txtConteudo.Text = teste;
For example, if he receives: "text ", continue: "text" even after going through Trim
. Shouldn’t it show "texttext"? How to get this result?
Why doesn’t it work? Show, give details. Working: https://dotnetfiddle.net/kaKhfO
– Maniero
it shows in the textbox the text with spaces... I edited the question!
– Aesir
How do you know? Put a copy of the screen showing that has the spaces. Maybe the problem is elsewhere.
– Maniero
You ask why the
Trim
does not work to remove space from the beginning of the string but in the code you were usingTrimEnd
. I mean, the problem was just a typo?– Caffé
no, the problem was how I was thinking the trim worked...
– Aesir
@Caffé is right. The title of the question does not match the code shown - if it hit, the whitespace would have been removed. Clearly it was a typo and the question must be closed.
– dcastro
@dcastro I edited the question, I had put the trimEnd in the question by mistake, but explained there the problem
– Aesir
The question is not a typo, it is the ignorance about the resource to be used to get what you wanted.
– Maniero