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

7 Years
Discussion Span
Last Post by JOSheaIV

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;

Edited by Momerath: Fixed typo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.