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
john_farrellus
NA
42
0
RE: application scope variables ... cant access tthem...
Jan 7 2004 6:24 PM
Thread locked, for some reason (maybe a good reason). Create a class, and set some properties, or make the member variables public if you like... If you make the constructor static, you can fetch the values from the database for config file. Here is my solution to using Global variables in C#: public class SystemProfile { #region Member Variables private static string mstrCurrentLanguage; private static string mstrCurrentCulture; private static bool mblnUseMetricUnits; private static bool mblnRequireRace; private static bool mblnShowBMI; private static Guid mBMIProtocol; #endregion #region Constructor ///
/// Static, so it will force a load of the settings the first time they are requested. ///
static SystemProfile() { LoadSettings(); } #endregion #region Public/Private Static Methods ///
/// Will re-load the settings, used after they are changed. ///
public static void ReFresh() { LoadSettings(); } private static void LoadSettings() { Polar.Electro.US.TriFIT.Data.SystemProfile dataSystemProfile = new Polar.Electro.US.TriFIT.Data.SystemProfile(); xsdSystemProfile xsdProfile = dataSystemProfile.Load(); mstrCurrentLanguage = xsdProfile.SystemProfile[0].CurrentLanguage; mstrCurrentCulture = xsdProfile.SystemProfile[0].CurrentCulture; mblnUseMetricUnits = xsdProfile.SystemProfile[0].UseMetricUnits; mblnRequireRace = xsdProfile.SystemProfile[0].RequireRace; mblnShowBMI = xsdProfile.SystemProfile[0].ShowBMI; mBMIProtocol = new Guid(xsdProfile.SystemProfile[0].BMIProtocol); xsdProfile.Dispose(); dataSystemProfile.Dispose(); } #endregion #region Public Static Properties ///
/// Returns the current language the program is using. ///
public static string CurrentLanguage { get { return mstrCurrentLanguage; } } ///
/// Returns the culture settings the program is using. ///
public static string CurrentCulture { get { return mstrCurrentCulture; } } ///
/// Metric flag. ///
public static bool UseMetricUnits { get { return mblnUseMetricUnits; } } ///
/// Race flag. ///
public static bool RequireRace { get { return mblnRequireRace; } } ///
/// BMI Flag. ///
public static bool ShowBMI { get { return mblnShowBMI; } } ///
/// BMI Protocol. ///
public static Guid BMIProtocol { get { return mBMIProtocol; } } #endregion }
Reply
Answers (
1
)
answer to gerrb's
listview checkboxs column