Okay so I am working on a massive program involving multiple forms, delegate calls, ext. Anyway I was wondering is there a way to make global values that can be accessed my any form or class? In otherwords, removing the need to pass in the variables.

Sorry this is rush I have to head off to work but wanted to get this question out. Thanks in advance

Recommended Answers

All 4 Replies

You can make a public globals class with public static fields representing the "global" variables. Not exactly a good design, but it works.

dang, can I get an example, do you mean like declaring the variables in a namespace? (Like you would delegates)

namespace MyGlobals {
    public static sealed class Global {
        public static int ScreenWidth = 1024;
    }
}

// somewhere else in your code
    int width = Global.ScreenWidth;

Cool I'll have to try that, that looks like what I wanted

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.