Solved

Properties.Settings.Default, multiple values

Posted on 2010-11-11
7
460 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
  • 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error in JQuery 5 53
Wav problem 4 27
Web Form VB.Net  import CSV 4 39
Cant save 3D 4 21
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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