Solved

instr c#

Posted on 2009-03-31
5
1,182 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
install app on other machine 13 32
Events in static methods 3 50
How to get the web content with different encodings 2 28
c# string handling 1 27
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

895 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

13 Experts available now in Live!

Get 1:1 Help Now