Can someone please tell me why the code below works but if I move the Application.Run(new Form1(env)) statement to be outside the brackets as in:
if (key != null)
{
env = (string)key.GetValue("Environment");
key.Close();
}
Application.Run(new Form1(env));
it generates a message saying that env is an unassigned local variable
Code that works:
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
string env;
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\VB and VBA Program Settings\Fisk\Installation");
if (key != null)
{
env = (string)key.GetValue("Environment");
key.Close();
Application.Run(new Form1(env));
}
}
}```