Solved

instr c#

Posted on 2009-03-31
5
1,181 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
Comment Utility
if(sTemp.Contains("experts-exchange.com")
{
   //response.write
}
0
 
LVL 142

Expert Comment

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

Author Comment

by:2Pru
Comment Utility
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
Comment Utility
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
Comment Utility
ah.. had sTemp and sFind switched around in my original code... Thanks everyone!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

15 Experts available now in Live!

Get 1:1 Help Now