[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

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
0
TimSweet220
Asked:
TimSweet220
1 Solution
 
Naman GoelCommented:
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now