Is it possible to initialize the variable like this:
class A
{
public int variable;
}
class B : A
{
variable = 123;
}
instead of using contructor like this? :
class A
{
public int variable;
}
class B : A
{
public B()
{
variable = 123;
}
}
Here : Initialize class fields in constructor or at declaration?
These two ways seems to be equivalent, but using the 1st way in derived class seems to be illegal. Then, is it possible to initialize variables in the other way than using constructor?