Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a method as soon as constructor is completed?

Tags:

c#

constructor

How can I call a method every time when constructor is executed? In other words, Within a class, can I somehow call another method as soon as constructor is completed?

like image 504
Learner Avatar asked Dec 02 '25 05:12

Learner


1 Answers

You can just call the method as the last line of the constructor.

Alternatively if you don't own the class you can go for Aspect Oriented Programming ( http://en.wikipedia.org/wiki/Aspect_oriented_programming )

like image 95
Stilgar Avatar answered Dec 03 '25 18:12

Stilgar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!