G
Guest
Hello,
I have this situation where I have two overloaded constructors and I would
like to call one constructor from another without using the initializer way.
I.e. without doing:
public myClass(/*param list*/) : this(/* more param list */)
internal myClass(/*more param list */)
(Firstly if the terminology that I am using is wrong then I apologise and I
would appreciate it if you could tell the correct terminology.)
The reason why I don't want to call one constructor from another like this
is because I have to perform some statements before the call to the
overloaded constructor. So I would like to do something like this:
public myClass(/*param list*/)
{
// do some stuff
// ...
this(/*more param list*/);
}
internal myClass(/*more param list*)
{
// initialise the class
}
Is this possible without using methods:
public myClass(/*param list*/)
{
// do some stuff
Init(...);
}
internal myClass(/*more param list*)
{
Init(...);
}
protected Init(...)
{
// initialise the class
}
I think it would cleaner to only use constructors and not use methods but is
it possible?
Thank you
Sidharth
I have this situation where I have two overloaded constructors and I would
like to call one constructor from another without using the initializer way.
I.e. without doing:
public myClass(/*param list*/) : this(/* more param list */)
internal myClass(/*more param list */)
(Firstly if the terminology that I am using is wrong then I apologise and I
would appreciate it if you could tell the correct terminology.)
The reason why I don't want to call one constructor from another like this
is because I have to perform some statements before the call to the
overloaded constructor. So I would like to do something like this:
public myClass(/*param list*/)
{
// do some stuff
// ...
this(/*more param list*/);
}
internal myClass(/*more param list*)
{
// initialise the class
}
Is this possible without using methods:
public myClass(/*param list*/)
{
// do some stuff
Init(...);
}
internal myClass(/*more param list*)
{
Init(...);
}
protected Init(...)
{
// initialise the class
}
I think it would cleaner to only use constructors and not use methods but is
it possible?
Thank you
Sidharth