(Update : I move those two variables from inside namespace block to class block)
I create a window form project named TheProject, the program structure is as below.
I also define two variables, TheVariable_A and TheVariable_B, however, the ways to
assign value to variable are different, TheVariable_A is assigned value immediately
after it is declared, and TheVariable_B is assigned value in MainForm() block,
Could you help to show what's the difference between these two ways ?
Which one is better or a standard one ?
Thanks of your prompt and detailed response.
namespace TheProject
{
public partial class MainForm : Form
{
int TheVariable_A = 10;
int TheVariable_B;
public MainForm()
{
InitializeComponent();
TheVariable_B = 1;
}
void TheFunction()
{
}
}
}