Solved

instr c#

Posted on 2009-03-31
5
1,188 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
[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
  • 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 143

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

737 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