troubleshooting Question

Using App.Config to set const variables

Avatar of alpacaman
alpacaman asked on
.NET Programming
7 Comments1 Solution5979 ViewsLast Modified:
C# .net

I have a class, and one of the members I want to assign to the value in the app.config.  It's a constant value though, and I get a

"The expresstion beign assigned to 'blah' must be constant"

class z{
 private const int x = Convert.ToInt16(ConfigurationManager.AppSettings["x"]); //error line

 public z(){}
} // end class

How can I use the app.config to set up constant values within the class?
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros