PC Review


Reply
Thread Tools Rate Thread

Contains and StringComparison.InvariantCultureIgnoreCase

 
 
Shapper
Guest
Posts: n/a
 
      5th Feb 2011
Hello,

I have the following:

String.Equals(a.Author, "CamÕes",
StringComparison.InvariantCultureIgnoreCase);

However a.Author has more than one word. So what I was really looking
for is something like:

a.Author.Contains("CamÕes",
StringComparison.InvariantCultureIgnoreCase);

How can I do this?

Thank you,

Miguel
 
Reply With Quote
 
 
 
 
Shapper
Guest
Posts: n/a
 
      5th Feb 2011
On Feb 5, 4:36*pm, Peter Duniho <NpOeStPe...@NnOwSlPiAnMk.com> wrote:
> On 2/6/11 12:16 AM, Shapper wrote:
>
> > Hello,

>
> > I have the following:

>
> > * *String.Equals(a.Author, "CamÕes",
> > StringComparison.InvariantCultureIgnoreCase);

>
> > However a.Author has more than one word. So what I was really looking
> > for is something like:

>
> > * * a.Author.Contains("CamÕes",
> > StringComparison.InvariantCultureIgnoreCase);

>
> > How can I do this?

>
> There are lots of discussions over the past few years on the topic,
> which Google Groups could have turned up for you. *But the short answer
> is to use the string.IndexOf() method.
>
> It's not the only way, and depending on the exact scenario might not
> even be the completely best, optimal way. *But it seems pretty
> straightforward and readable to me.
>
> Pete


Yes, I am trying the following:

String text = "O livro de Camões";

Boolean a = text.IndexOf("livro",
StringComparison.InvariantCultureIgnoreCase) != -1;

Boolean b = text.IndexOf("LIVRO",
StringComparison.InvariantCultureIgnoreCase) != -1;

Boolean c = text.IndexOf("Camões",
StringComparison.InvariantCultureIgnoreCase) != -1;

Boolean d = text.IndexOf("CAMÕES",
StringComparison.InvariantCultureIgnoreCase) != -1;

Boolean e = text.IndexOf("Camoes",
StringComparison.InvariantCultureIgnoreCase) != -1;

Boolean f = text.IndexOf("Camões",
StringComparison.InvariantCultureIgnoreCase) != -1;

The only that fails is Camoes ... But I would like to have it pass.
Any idea why is not working?

Thank You,
Miguel
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Equals(String, String, StringComparison) ? csharper Microsoft C# .NET 1 19th Dec 2010 08:40 PM
RichTextBoxFinds & StringComparison Lloyd Dupont Microsoft Dot NET Framework 0 11th Dec 2005 02:08 AM
RichTextBoxFinds & StringComparison Lloyd Dupont Microsoft Dot NET Framework Forms 0 11th Dec 2005 02:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:12 PM.