According to the intellisense help, string.Trim() "Removes all occurances or
white space characters from the beginning and end of this instance."
However, the follow code does not appear to modify s.
s.Trim('\r');
While the follow code DOES modify s.
s = s.Trim(\r');
I understand that the help text quoted above is for the version of this
method that takes no arguments. But I would assume that variations of Trim
work the same fundamental way.
If this is modifying this instance, why do I only get the effect if I assign
the result?
Thanks.

Signature
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Jonathan Wood - 16 Jul 2006 18:42 GMT
Whoops! Wrong group. Reposted in microsoft.public.dotnet.languages.csharp.

Signature
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
> According to the intellisense help, string.Trim() "Removes all occurances
> or white space characters from the beginning and end of this instance."
[quoted text clipped - 15 lines]
>
> Thanks.
Bruno van Dooren [MVP VC++] - 16 Jul 2006 20:21 GMT
> Whoops! Wrong group. Reposted in microsoft.public.dotnet.languages.csharp.
No worries. This group is about .NETish things as well.
You problem is that System::Strings are immutable.
the Trim method returns a new string without the whitespace.
You can then assign that string to s again, after which the original s
string can be garbage collected.
None of the methods you can call on a System::String can change the string
itself.

Signature
Kind regards,
Bruno van Dooren
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"