Solved

indexofany vs contains

Posted on 2006-06-25
3
317 Views
Last Modified: 2010-04-16
Just curious what is the difference between .indexofany and .contains.



0
Comment
Question by:bman9111
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 125 total points
Comment Utility
Contains takes a string and returns a bool if it is found in the search string.

IndexOfAny takes an array of characters to search for and returns the index position of the first one, if any, found.
0
 
LVL 8

Author Comment

by:bman9111
Comment Utility
ok....is there a way to make contains look for a word no matter what the case maybe be.

I noticed that is i do a .contains("TT")
if only will look for TT, but what if it is Tt or TT....

Right now I am doing like 3 statement to achieve it to find it. Is that correct?
0
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
Use ToLower() on the string to convert it to lowercase for the comparison:
 
            string s1 = "This is TT";
            MessageBox.Show(s1.ToLower().Contains("tt").ToString());
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now