Click to See Complete Forum and Search --> : Help on Trim string not really working ?


serge calderara
04-07-2004, 06:04 AM
Dear all,

I have a string represented as follow:

myString =" Hello"

This string is retrive from a byte array by using following code:

myString = asci.GetString(bData, 0, 8) where bData is an array of byte.

I need to remove character in front of Hello for that I use:
myString.Trim() which is suppose to remove space.

In my byte array, the value of those trim character is 32 whcih is representating a space.

My space character are not removed after trim function is call, what I am doing wrong?

pclement
04-07-2004, 09:15 AM
Yes, it would be nice if it worked that way but it doesn't. The call to the method actually returns the string value with the leading and trailing spaces removed:

myString = myString.Trim()

serge calderara
04-07-2004, 09:18 AM
But this is wrong for my case, becasue calling this Trim function returns the same string for me...

Why space is still here?

pclement
04-07-2004, 10:46 AM
So what does the following code display in the Output window:

myString = myString.Trim()
Console.WriteLine(Asc(myString.Substring(0, 1)))

serge calderara
04-08-2004, 02:49 AM
OUps sorry, I found out why it was not working.
A miss typing.

thnaks a lot for your help