Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

indexofany vs contains

Just curious what is the difference between .indexofany and .contains.



0
bman9111
Asked:
bman9111
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
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
 
bman9111Author Commented:
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
 
Carl TawnSystems and Integration DeveloperCommented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now