Solved

instr c#

Posted on 2009-03-31
5
1,184 Views
Last Modified: 2012-05-06
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
Comment
Question by:2Pru
  • 2
  • 2
5 Comments
 
LVL 22

Accepted Solution

by:
p_davis earned 125 total points
ID: 24033309
if(sTemp.Contains("experts-exchange.com")
{
   //response.write
}
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24033335
that code actually should do it.
so, you might be "overlooking" something stupid like case sensitivity, or the like...
0
 

Author Comment

by:2Pru
ID: 24033475
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
 
LVL 22

Expert Comment

by:p_davis
ID: 24033501
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
 

Author Comment

by:2Pru
ID: 24033518
ah.. had sTemp and sFind switched around in my original code... Thanks everyone!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 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