?
Solved

ASP.NET C# like statement

Posted on 2008-02-06
3
Medium Priority
?
681 Views
Last Modified: 2013-11-26
My code below works...but I need to have a "Like" statement instead of ==

How do I do that in C#?I want the if (strMLS == "F900052") to be

if (strMLS like "F%")


case "East":
                    if (strMLS == "F900052")
                    {
                        strOfficeNumber = strContactLine + ": 999.999.9999";
                    }
                    else
                    {
                        strOfficeNumber = strContactLine + ": 888.888.8888";
                    }
                              
                              break;
0
Comment
Question by:lrbrister
3 Comments
 
LVL 6

Expert Comment

by:Hardi
ID: 20838258
if(strMLS.IndexOf("F") == 0)  // <-- begins with F

if you need LIKE "%asdf%"
it would be
yourString.IndexOf("asdf") >= 0
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 2000 total points
ID: 20838266
 string strMLS;
        strMLS = "sdfghF900052sasd";

        if (strMLS.Contains("F900052") == true)
        {
            strOfficeNumber = strContactLine + ": 999.999.9999";
        }
        else
        {
            strOfficeNumber = strContactLine + ": 888.888.8888";
        }
0
 

Author Closing Comment

by:lrbrister
ID: 31428745
pratima_mcs:  Perfect...thanks
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

589 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