<2017 September>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

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, 08 October 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, 08 October 2008 14:37:23 (W. Europe Daylight Time, UTC+02:00)  #    Comments [3]

 



Wednesday, 08 October 2008 15:14:22 (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, 08 October 2008 15:46:48 (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, 08 October 2008 16:19:41 (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 2017 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.