public class AppContext : ApplicationContext
{
public static AppContext Current { get; private set; }
public AppContext() {
if (Current == null)
Current = this;
this.init();
}
public AppContext(Form mainForm) : this() {
this.MainForm = mainForm;
}
private void init() {
// ...
}
int i = 0;
public int I { get { return i++; } }
}
* This source code was highlighted with Source Code Highlighter.
Ну и теперь, собственно, в любом месте приложения:
MessageBox.Show(AppContext.Current.I + "");