Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / July 2006

Tip: Looking for answers? Try searching our database.

string.Trim() Behavior

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan Wood - 16 Jul 2006 18:36 GMT
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"


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.