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
Solved

instr c#

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

861 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