473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Trim function

SK
Trim function doesnt actually trim the spaces.Can anyone
help
Jul 21 '05 #1
2 1564
SK <an*******@discussions.microsoft.com> wrote:
Trim function doesnt actually trim the spaces.Can anyone
help


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

My *guess* is that you think it changes the string you call it on - it
doesn't, as strings are immutable. Instead, it returns a new string
which is a trimmed version of the old string.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
SK
Thanks ....now it works
i was having something like the code below.
i assigend splitContent.Trim() to a string varibale and
used it.....it works fine

string splitContent = splitContentArray[index];
splitContent.Trim();
if (splitContent.Length > 0)
splittedContents.Add(splitContent);

-----Original Message-----
SK <an*******@discussions.microsoft.com> wrote:
Trim function doesnt actually trim the spaces.Can anyone help
Could you post a short but complete program which

demonstrates theproblem?

See http://www.pobox.com/~skeet/csharp/complete.html for details ofwhat I mean by that.

My *guess* is that you think it changes the string you call it on - itdoesn't, as strings are immutable. Instead, it returns a new stringwhich is a trimmed version of the old string.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Simon | last post by:
Hi, I have written a function to trim char *, but I have been told that my way could be dangerous and that I should use memmove(...) instead. but I am not sure why my code could be 'dangerous'...
12
by: Robert Mark Bram | last post by:
Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*$/g, ''); } The problem is that this doesn't trim instances of the...
3
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
11
by: Darren Anderson | last post by:
I have a function that I've tried using in an if then statement and I've found that no matter how much reworking I do with the code, the expected result is incorrect. the code: If Not...
7
by: Sascha Herpers | last post by:
Hi, what is the difference between the trim function and the trim String-member? As far as I see it, both return the trimmed string and leave the original string unaltered. Is any of the two...
22
by: Terry Olsen | last post by:
I have an app that makes decisions based on string content. I need to make sure that a string does not contain only spaces or newlines. I am using the syntax 'Trim(String)" and it works fine. I...
31
by: rkk | last post by:
Hi, I've written a small trim function to trim away the whitespaces in a given string. It works well with solaris forte cc compiler, but on mingw/cygwin gcc it isn't. Here is the code: char...
12
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I trim whitespace - LTRIM/RTRIM/TRIM?...
5
by: Marjeta | last post by:
I'm trying to very that the user actually entered something in the form, and not just spaces. I guess the problem is in the first line of isBlank() function. I've tried the following:...
8
by: Keith Thompson | last post by:
Kevin Smith <no@spam.comwrites: 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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.