string.Trim() behavior

  • Thread starter Thread starter Kevin Smith
  • Start date Start date
K

Kevin Smith

Hi,

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.
 
[Removed comp.lang.c - why did you try to follow up there when this has
nothing to do with C?]

Kevin Smith said:
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?

None of the string methods *actually* modify the object they're called
on - strings are immutable. It's sloppy wording in the docs, basically
:(
 
Kevin Smith said:
According to the intellisense help, string.Trim() "Removes all occurances
or white space characters from the beginning and end of this instance."
[snip]

You posted this to microsoft.public.dotnet.languages.csharp, where I
presume it's topical. Why on Earth did you redirect followups to
comp.lang.c?

Anyone else replying to Kevin Smith's article, please *ignore* the
Followup-To header and post only to the csharp group. Thanks.
 
Hi

I want to be able to read answers at work which doesnt take
microsoft.public.dotnet.languages.csharp, so I put followups to the more
common comp.lang.c group.

Best

KS


Kevin Smith said:
According to the intellisense help, string.Trim() "Removes all occurances
or white space characters from the beginning and end of this instance."
[snip]

You posted this to microsoft.public.dotnet.languages.csharp, where I
presume it's topical. Why on Earth did you redirect followups to
comp.lang.c?

Anyone else replying to Kevin Smith's article, please *ignore* the
Followup-To header and post only to the csharp group. Thanks.
 
Kevin Smith said:
I want to be able to read answers at work which doesnt take
microsoft.public.dotnet.languages.csharp, so I put followups to the more
common comp.lang.c group.

That's not at all appropriate though - C and C# are completely
different languages.

Do you not have access to Google Groups from work?
 
Kevin Smith wrote, On 08/10/08 21:01:
Hi

I want to be able to read answers at work which doesnt take
microsoft.public.dotnet.languages.csharp, so I put followups to the more
common comp.lang.c group.

Why do you think it is appropriate to direct posts about c# to
comp.lang.c? C is a completely different language and C# IS NOT TOPICAL.

If your house is closer to a customer I'm visiting should I just barge
in to your house and stay? After all it is more convenient than staying
at home or paying for a hotel.

Please keep your C# somewhere it is topical. Also keep your top-posting
where it is acceptable, which is not here.


Please everyone keep the responses about csharp on the csharp group as
Kevin requested.
 
Back
Top