Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

instr c#

Posted on 2009-03-31
5
Medium Priority
?
1,192 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 500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 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