Solved

Properties.Settings.Default, multiple values

Posted on 2010-11-11
7
464 Views
Last Modified: 2012-05-10
I'm working on an application an we need conditional statements for multiple locations.
There could be two or more locations.

Is there another way of coding for a certain location?
So far, I would just use a conditional statement.
if (Properties.Settings.Default.Location == "abc")
                {
                   //do stuff
                }

Open in new window

0
Comment
Question by:JRockFL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 17

Accepted Solution

by:
Daniel Reynolds earned 500 total points
ID: 34115568
well most obvious is using switch(){} but that may not save you much.

create the do stuff method()

switch (Properties.Setting.Default.Location)
{
     case "abc":
              dostuff("abc");
               break;
    case "bcd":
              dostuff("bcd")
              break;
}
0
 
LVL 8

Author Comment

by:JRockFL
ID: 34115609
Yeah I thought about that too, What about creating an enumerator?
Then when I instantiate the class,  I can set a property with the current location.

if (Location == Locations.Texas)
{
    //do stuff
}
0
 
LVL 17

Expert Comment

by:Daniel Reynolds
ID: 34115797
an enumerator will still require you to check which it is somehow using if or switch.

The creation of a class with methods / branches that will process depending on the value of its location property would be a clean way to implement this, but you still need to check the value in the class, just not in the calling method.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 6

Expert Comment

by:ajb2222
ID: 34116204
You could create a class that has specific methods and properties

then create a class for each location based on the first class you created and override any mothods or properties that are diferent for that location

Then when some processing just call the correct method.

Look into Object Oriented Programming.

0
 
LVL 8

Author Comment

by:JRockFL
ID: 34116299
ajb2222,

can you provide a code sample?
0
 
LVL 6

Expert Comment

by:ajb2222
ID: 34122123
what I am talking about is  inheritance and  polymorphism which are two major concepts in object oriented programming.  The link is an example that explains the concept and how to apply it.

http://www.codeproject.com/KB/cs/csharpintro01.aspx

0
 
LVL 8

Author Closing Comment

by:JRockFL
ID: 34248524
Thank you!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

630 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