using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace ProgrammerGuide_001
{
public class WinForm:Form
{
private Button button1;
private TextBox textBox1;
public WinForm()
{
}
static void Main(string[] args)
{
WinForm myFrm = new WinForm();
myFrm.button1 = new Button();
myFrm.textBox1 = new TextBox();
myFrm.Text = "my first window application";
Application.Run(myFrm);
}
}
}
I have a question that when I declare 2 object variable like this:
private Button button1;
private TextBox textBox1;
why I can't instantiate with the following statements:
button1=new Button();
textBox1=new TextBox();
but this code can:
myFrm.button1 = new Button();
myFrm.textBox1 = new TextBox();