3
This is C#’s mistake, or I’m doing something wrong because in my logic it should work perfectly.
public partial class Form1 : Form
{
Banco Bbanco;
Bbanco = new Banco();
}
3
This is C#’s mistake, or I’m doing something wrong because in my logic it should work perfectly.
public partial class Form1 : Form
{
Banco Bbanco;
Bbanco = new Banco();
}
6
Cannot make assignments in the body of a class separate from the declaration.
This doesn’t work:
public class Test
{
Banco BBanco;
BBanco = new Banco();
}
It may, however, make the allocation at the time of the declaration:
public class Test2
{
Banco BBanco = new Banco();
}
Or you can assign within a method/constructor:
public class Test3
{
Banco BBanco;
public Test3()
{
BBanco = new Banco();
}
}
You can consult the examples here.
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
or within the manufacturer :)
– Marco Souza
@Marconciliosouza I edited to avoid doubt, but a constructor can be considered a method
– Omni
That cool, so there is the possibility to do assignments outside of a class that super interesting, thank you very much.
– rock.ownar
@rock.ownar, in reality it is outside a method or builder. outside of a class you would be inside the namespace. that also would not be possible.
– Marco Souza