Solved

indexofany vs contains

Posted on 2006-06-25
3
325 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
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

816 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

10 Experts available now in Live!

Get 1:1 Help Now