• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1193
  • Last Modified:

instr c#

What's the equilavent for instr in c# i've already tried indexOf and Contains and neither are working. here's an example:
string sTemp = "http://www.experts-exchange.com/Programming/Languages/C_Sharp/newQuestionWizard.jsp"
if (sTemp.IndexOf("experts-exchange.com") != -1)
{
Response.Write("We found it")
}
string sTemp = "http://www.experts-exchange.com/Programming/Languages/C_Sharp/newQuestionWizard.jsp"
if (sTemp.IndexOf("experts-exchange.com") != -1)
{
Response.Write("We found it")
}

Open in new window

0
2Pru
Asked:
2Pru
  • 2
  • 2
1 Solution
 
p_davisCommented:
if(sTemp.Contains("experts-exchange.com")
{
   //response.write
}
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
that code actually should do it.
so, you might be "overlooking" something stupid like case sensitivity, or the like...
0
 
2PruAuthor Commented:
still not working tried:


string sTemp = "http://www.experts-exchange.com/Programming/Languages/C_Sharp/newQuestionWizard.jsp";
string sFind = "experts-exchange.com";
sTemp = sTemp.ToUpper();
sFind = sFine.ToUpper();
if (sTemp.Contains(sFind))
{
Response.Write("We found it");
}

Open in new window

0
 
p_davisCommented:
you have one slight misspelling in sFine.ToUpper();

should be

sFind.ToUpper();

and this code works for me in winforms with a message box instead of response.write
0
 
2PruAuthor Commented:
ah.. had sTemp and sFind switched around in my original code... Thanks everyone!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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