?
Solved

indexofany vs contains

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



0
Comment
Question by:bman9111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 16979472
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
ID: 16979580
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
ID: 16979630
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

770 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