"kruskal" <kr*****@gazeta.plwrote in message
news:op***************@odwrotnie.kolo.pl...
So what should I do to a = new A(); will raise important_method()?
Maybe if you were more specific about what you're trying to do, people could
give you better answers.
Your question appears to be saying that anytime you assign a reference of
type A to a variable, you want "important_method()" to be called. This is a
very unusual requirement, and probably indicates a failure with respect to
the design of the code. What is in "important_method()" that you feel needs
to be run every time you assign a reference of type A to a variable?
In C++, you could overload the assignment operator. I don't recall if this
is possible in C#, but if it is you might be able to do what you want doing
that. However, it still begs the question of why it is you think this very
unusual practice needs to occur in your own code. More than likely, it
shouldn't.
And if you *don't* want your "important_method()" to be called every time
you assign a reference of type A to a variable, then you have asked the
wrong question. Rewording the question so that you ask the question you
intended will help, in that case.
Pete