Or, if you're not sure what's in the string, safer to say
str = (str == null) ? null : str.Trim();
As an aside, I very rarely use Trim() because almost invariably what I
want to do isn't simply trim a string, but do something more akin to
XPath's normalize_space() function: remove all leading and
Oh I must have read the question wrong since thats the defailt :-)
wouldn't expect someone to ask how.
On Thu, Apr 10, 2008 at 4:54 PM, Marc Brooks <[EMAIL PROTECTED]> wrote:
> > > I am looking for a case sensitive string- or generic dictionary, meaning
> > > the
> > > key should not automatica
http://msdn2.microsoft.com/en-us/library/t97s7bs3.aspx
Pretty straight forward:
String myString = " Testing Testing 123 ";
Console.WriteLine(myString.Trim());
This will produce "Testing Testing 123" (notice the lack of spaces before
and after the string contents). There is also TrimEnd() an
> Can anyone tell me how to use string function Trim in C#?
The thing to remember is that string are immutable in C#/ .Net, so
calling Trim against one doesn't change THAT string, it returns a NEW
string... you want this:
string foo = "Blah ";
foo = foo.Trim();
--
"Your lack of planning DOES c
> > I am looking for a case sensitive string- or generic dictionary, meaning the
> > key should not automatically be converted to lower case.
>
> Dictionary nodes = new Dictionary(
> StringComparer.OrdinalIgnoreCase ) ?
He want's sensitive, not insensitve:
Dictionary nodes = new Dictionary(Strin
Can anyone tell me how to use string function Trim in C#?
Sincerely,
Tracy Ding
XYPRO Technology
USA HQ phone: +1-805-583-2874
===
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.d
Dictionary nodes = new Dictionary(
StringComparer.OrdinalIgnoreCase ) ?
On Thu, Apr 10, 2008 at 2:28 PM, Robert Fuchs <[EMAIL PROTECTED]> wrote:
> I am looking for a case sensitive string- or generic dictionary, meaning the
> key should not automatically be converted to lower case.
>
>
>
> Any i
Robert Fuchs <[EMAIL PROTECTED]> wrote:
> I am looking for a case sensitive string- or generic dictionary, meaning the
> key should not automatically be converted to lower case.
What's wrong with Dictionary?
-- Barry
--
http://barrkel.blogspot.com/
===
This lis
I am looking for a case sensitive string- or generic dictionary, meaning the
key should not automatically be converted to lower case.
Any idea?
Regards, Robert
===
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your