Hi
IN windows form application i want to use Global variables. Where i should declare them
public static SAPbouiCOM.Application oApplication = null;
public static SAPbobsCOM.Company oCompany = null;
namespace Employee
{
static class Program
{
public static SAPbouiCOM.Application oApplication = null;
public static SAPbobsCOM.Company oCompany = null;
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
try
{
CreateConnection();
Menu oMenuItems = null;
oMenuItems = new Menu();
// Start Message Loop
System.Windows.Forms.Application.Run();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}
}
Thanks
Amit MohantyPosted Apr 19, 2024, 9:34 AM
You can declare global variables in a few different places depending on your requirements:
Then, you can access these settings using Properties.Settings.Default.VariableName in your code.
Sam HobbsPosted Apr 20, 2024, 9:01 PM
A true global variable does not belong to a class and C# requires everything to be in a class.