Hi,
In button1_Click(), how can I get "aValue" from Main(), somthing like:
static class Program
{
[STAThread]
static void Main()
{
int aValue = 1;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDe...
Application.Run(new Form1());
}
}
public partial class Form1 : Form
{
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine("aValue = " + aValue);
}
}
I will appreciated for your code, I am a beginner.
Loading
VulpesPosted Dec 7, 2013, 12:02 PM
DavePosted Dec 7, 2013, 3:34 PM
VulpesPosted Dec 7, 2013, 2:08 PM
However, if you right click on the project name in Solution Explorer, select Properties from the dropdown and then, under the Application tab, change the output type to Console application, a console will be attached and such statements will work fine.
DavePosted Dec 7, 2013, 1:21 PM
One more thing:
Why I can also use Console.Writeline() in
private void button1_Click(object sender, EventArgs e)?
VulpesPosted Dec 7, 2013, 1:00 PM
DavePosted Dec 7, 2013, 12:34 PM
I tried and got error in Form1 button1_Click():
The name 'aValue' does not exist in the current context