TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
HumptyNotSoDumpty
NA
23
0
Storing Variables for Global Use In Application
Jul 23 2004 4:57 AM
I am having some trouble with a simple problem of storing variables within my program. I am retrieving settings from within an XML file, which is working fine. But I need to store the variables in my program for the duration of its execution. I figured I need to store them in a separate .cs (Class) file within the project, possibly as Attributes. Then use the Set and Get methods to control the values. I do want the values to be stored in a separate class of their own so that they can be controlled and used by methods in several other classes. * Am I approaching the problem the correct way? * If I do the following, will the values remain set, unless modified, until the program terminates? // Start of Settings Class using System; namespace Settings { // Main class, which will have several sub-classes internal class clsMain { // Sub-class, which is one of several classes within the Main class internal class clsSetting : Attribute { protected double dValue; public double DoubleValue { get{return dValue;} set{dValue = value;} } protected string sValue; public double StringValue { get{return sValue;} set{sValue = value;} } } } } // End of Settings Class // Sample code used in different class, within a different .cs file in the project private clsMain.clsSetting Setting = new clsMain.clsSetting(); // Store values in Settings Setting.DoubleValue = 12345; Setting.StringValue = "TestValue"; // Retrieve values from Settings MessageBox.Show("DoubleValue = " + Setting.DoubleValue.ToString()); MessageBox.Show("StringValue = " + Setting.StringValue());
Reply
Answers (
3
)
Generate password
Found a low surrogate char without a preceding high...