471,627 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

How to create application wide var?

I'd like to create an application wide variable in a winform app. I
can do this on my start up form by reading in some values from a config
file (since these values may change in the future) and assigning them
to a public var. From there, I'd always have to reference the start up
form. Is there a better way?

Thanks,
Brett

Dec 7 '05 #1
2 1407
You can create a class with static fields that you can access.

"Brett Romero" <ac*****@cygen.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
I'd like to create an application wide variable in a winform app. I
can do this on my start up form by reading in some values from a config
file (since these values may change in the future) and assigning them
to a public var. From there, I'd always have to reference the start up
form. Is there a better way?

Thanks,
Brett

Dec 7 '05 #2
Great! I actually created a DLL with a structure and reference them
from there, since it will be used across a few apps.

I do this through out my application. It is all winforms. I'd like to
put the code below into one place and reference it. It has to be an
instance as you can see. I want to abstract it somehow because the
enum references below could change and I don't want to go through the
app doing find/replace.

private ErrorHandling.LogErrors ErrorHandler = new
ErrorHandling.LogErrors(Configuration.ErrorLogging .Tracker_EventLogSource,
Configuration.ErrorLogging.Tracker_EventLogName);

Brett

Dec 8 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mr.Tickle | last post: by
3 posts views Thread by Jonathan Mcdougall | last post: by
6 posts views Thread by Shibu | last post: by
16 posts views Thread by Fernando Arámburu | last post: by
2 posts views Thread by Mark Olbert | last post: by
3 posts views Thread by =?Utf-8?B?Um9nZXIgVHJhbmNoZXo=?= | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.