C#  Bool enable code

Posted on 2011-10-10
Last Modified: 2012-05-12
I am working on a app that is comparing a bool to set controls on a page.
The code I have issues with is this (generically)
 if (m_strProviderA == "747991" || m_strProviderA == "362210" || m_strProviderA == "0")

Is there not a better way to write this?

Question by:TimSweet220
    LVL 13

    Accepted Solution

    do something like this:

    string[] values=new string[]{ "747991","362210","0"};

    Open in new window

    this way you can just add some more values in array and the condition will automatically work for everything.

    Author Closing Comment

    Thanks for the quick reply.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    754 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

    16 Experts available now in Live!

    Get 1:1 Help Now