<September 2019>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

On this page...

Search

Links

Member of...


ASP Insiders

MVP Visual Developer ASP/ASP.NET

Enter CodeZone

Blog Categories

Microsoft

Blogroll

Deutsche Resourcen

Management

Sign In
 

#  Wednesday, October 8, 2008

IndexOf has overloads that take StringComparison which allows me to specify how the comparison is done: culture (in)sensitive, case (in) sensitive, et cetera. Why is it that Contains doesn't sport such an overload? IndexOf makes a LINQ query look so much more ugly than Contains...

Categories: .NET | C#
Wednesday, October 8, 2008 2:37:23 PM (W. Europe Daylight Time, UTC+02:00)  #    Comments [3]

 



Wednesday, October 8, 2008 3:14:22 PM (W. Europe Daylight Time, UTC+02:00)
When you use Contains in a linq query (at least for Linq-to-SQL) then it will be translated to a like anyways (meaning case insensitive)

Using IndexOf with a StringComparison argument on Linq-to-SQL will trow a notsupportedexception.

On the other side, when using Linq-to-Objects, the first one will be case senstive and the second will work :P
Steve
Wednesday, October 8, 2008 3:46:48 PM (W. Europe Daylight Time, UTC+02:00)
To qualify: in this specific case I was using it against an object collection in memory, not LINQ to SQL. No exceptions are thrown in this case.
Chris
Wednesday, October 8, 2008 4:19:41 PM (W. Europe Daylight Time, UTC+02:00)
I forget to tell the most important part :P that the current implementation is very inconsistent, they both do it completely different, I agree 100% with your post.
Steve
Comments are closed.

© Copyright 2019 Christoph Wille

newtelligence dasBlog 2.3.9074.18820
Subscribe to this weblog's RSS feed with SharpReader, Radio Userland, NewsGator or any other aggregator listening on port 5335 by clicking this button.   RSS 2.0|Atom 1.0  Send mail to the author(s)

 
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.