C# Bool enable code

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?

Thanks
TimSweet220Asked:
Who is Participating?
 
Naman GoelSoftware engineer 1Commented:
do something like this:

 
string[] values=new string[]{ "747991","362210","0"};
          
            if(values.Contains<string>(m_strProviderA))
            {

            }

Open in new window


this way you can just add some more values in array and the condition will automatically work for everything.
0
 
TimSweet220Author Commented:
Thanks for the quick reply.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.