N
Nicolas
Hi,
How can one call a constructor in the same class as the constructor itself ?
Thanks.
How can one call a constructor in the same class as the constructor itself ?
Thanks.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
How can one call a constructor in the same class as the constructor itself ?
Mattias said:class Foo
{
public Foo(string s) { ... }
public Foo(int i) : this(i.ToString()) {}
// like this -> ^^^^^^^^^^^^^^^^^^^^
}
class Foo
{
public Foo(string s) { ... }
public Foo(int i) : this(i.ToString()) {}
// like this -> ^^^^^^^^^^^^^^^^^^^^
}
Richard said:Are you trying to "re-initialize" your instance using a specific constructor?
That's it exactly. I know that simply calling an init() method from both
the constructor and the place where I want to re-init is an option, but
I am just curious to see whether it's possible to do it with a ctor.
--
Truth,
James Curran =======================================
[erstwhile VC++ MVP] <<<<<<<<<<<<<<<< ??? =======================================
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Peter N Roth said:=======================================[erstwhile VC++ MVP] <<<<<<<<<<<<<<<< ??? =======================================
Hi James - why'd you "switch"?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.