Ideally, I would prefer not to have to change a global setting or override
any other interfaces.
BTW, does anyone know why documentation for .NET library methods don't have
a Return Value section where the return value is described? Seems really
strange to me that Microsoft didn't feel return values needed to be
documented.
--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
"Jonathan Wood" <jw...@softcircuits.com> wrote in message
news:u5553TrI...@TK2MSFTNGP15.phx.gbl...
> Can someone tell me how to compare two strings using a case-insensitive
> comparison.
>
> Ideally, I would prefer not to have to change a global setting or override
> any other interfaces.
>
Hi, IIRC in v 2.0 there is a new recommended way to handle string
comparisions
Ok, I found it in google :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/StringsinNET20.asp
> BTW, does anyone know why documentation for .NET library methods don't
> have a Return Value section where the return value is described? Seems
> really strange to me that Microsoft didn't feel return values needed to be
> documented.
Hi,
In general you do have it, only in some cases you do not have that section,
note that this is only for methods (not properties) that return something
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
In 2.0, use String.Compare (first, second,
StringComparison.OrdinalIgnoreCase)
(Or CurrentCultureIgnoreCase, or InvariantCultureIgnoreCase)
In 1.1, use String.Compare (first, second, true) if you're happy using
the current culture.
> Ideally, I would prefer not to have to change a global setting or override
> any other interfaces.
>
> BTW, does anyone know why documentation for .NET library methods don't have
> a Return Value section where the return value is described? Seems really
> strange to me that Microsoft didn't feel return values needed to be
> documented.
It does. In the case of String.Compare(string,string,StringComparison)
it's:
<quote>
Return Value
A 32-bit signed integer indicating the lexical relationship between the
two comparands.
Value
Condition
Less than zero
strA is less than strB.
Zero
strA equals strB.
Greater than zero
strA is greater than strB.
</quote>
--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
> In 1.1, use String.Compare (first, second, true) if you're happy using
> the current culture.
Ack! Okay, I see that now.
Can someone explain to me why we're using this syntax? I guess Compare is a
static function. But why is it not part of the string class? (i.e., string
s; s.Compare(first, second, true) or s.Compare(second, true)?
Thanks.
> It does. In the case of String.Compare(string,string,StringComparison)
> it's:
A few do. Many do not. For example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemCollectionsArrayListClassBinarySearchTopic.asp
--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Available for consulting: http://www.softcircuits.com/jwood/resume.htm
Well, having it as a static method means it's available without you
having to worry about whether or not either side is null. Yes, each of
the overloads *could* be available as an instance method too, but I'm
not sure it would give very much benefit.
> > It does. In the case of String.Compare(string,string,StringComparison)
> > it's:
>
> A few do. Many do not. For example:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpre
> f/html/frlrfSystemCollectionsArrayListClassBinarySearchTopic.asp
Every one of those overloads has a "Return value" section. It's only
the page listing the overloads which doesn't.
>> Can someone explain to me why we're using this syntax? I guess Compare is
>> a
>> static function. But why is it not part of the string class? (i.e.,
>> string
>> s; s.Compare(first, second, true) or s.Compare(second, true)?
>
> Well, having it as a static method means it's available without you
> having to worry about whether or not either side is null. Yes, each of
> the overloads *could* be available as an instance method too, but I'm
> not sure it would give very much benefit.
I guess. It's just seems less OOP to me this way.
Thanks.
Regards,
Jeff
*** Sent via Developersdex http://www.developersdex.com ***