This is C # error, or I'm doing something wrong because in my logic this should work perfectly.
public partial class Form1 : Form
{
Banco Bbanco;
Bbanco = new Banco();
}
This is C # error, or I'm doing something wrong because in my logic this should work perfectly.
public partial class Form1 : Form
{
Banco Bbanco;
Bbanco = new Banco();
}
You can not make assignments in the body of a class separate from the declaration.
This does not work:
public class Test
{
Banco BBanco;
BBanco = new Banco();
}
You can, however, do the assignment at the time of the declaration:
public class Test2
{
Banco BBanco = new Banco();
}
Or you can do the assignment within a method / constructor:
public class Test3
{
Banco BBanco;
public Test3()
{
BBanco = new Banco();
}
}
You can check out here examples.