Need an IS LIKE style regex for a C# Net app.

I inherited a web app written in C#, I'm not entirely fluent in C#. From what I understand there is no "IS LIKE" in C#, apparently you have to use regular expression.

What I need to do exactly, is evaluate a variable from the database and determine if it contains the letter 'W' or 'w'. and if it does add 3% to another variable.

My problem is that I don't know the syntax in C# to pull this off, I have the below code in place and working.

So really I need to determine if there's a W in their contract number, and if there is display my variable intCCplusFee if not, display intPaymentAmount.

        // if all validation is successful, we proceed

        // save selected payment amount to session

        if (txtAmount.Value.Trim() != "")
            Session.Add("PaymentAmount", txtAmount.Value);
            Session.Add("PaymentAmount", Session["Balance"]);

        // switch CC to a secure view for receipt and emails

        string ccNumber = txtCardNumber.Value;
        string stripCCNumber = "xxxx-xxxx-xxxx-" + ccNumber.Substring(ccNumber.Length - 4);

        Session.Add("stripCCNumber", stripCCNumber);
        Session.Add("txtCardName", txtCardName.Value);
        Session.Add("cboCardType", cboCardType.Text);
        Session.Add("txtEmail", txtEmail.Value);

        int intPaymentAmount = Convert.ToInt16(Session["PaymentAmount"]);
        double intCCplusFee = (intPaymentAmount * .03+intPaymentAmount);

Open in new window

Michael KnightAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
try this

if (s.Contains("w") || s.Contains("W")) {...}


if (s.ToUpper.Contains("W")) {...}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HainKurtSr. System AnalystCommented:
you can also try

if ((s.IndexOf("w") != -1) || (s.IndexOf("W") != -1)) {...}
if (s.ToUpper.IndexOf("W") != -1) {...}

Michael KnightAuthor Commented:
if (s.ToUpper.Contains("W")) worked a treat!

has the System namespace always included the .Contains method for c#?

Sheesh shows you how much I know about c#...
Michael KnightAuthor Commented:
RE: My original Author Comment...apparently .Contains is a .NET 2.0 and higher thang. So I I'm not as thick as I thought.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.