|Thanks a lot Scott,
carbon_golem wrote:Have you timed it yourself?
Nope I havent timed it yet, how do i do that?
I did look at the ildasm. Thanks a lot, it cleared a big stumble in the thought process.
Okay agreed that with a method call, there is an additional overhead for puting the instruction on the stack and the return.
However compare it to the scenario where the class A and class B objects are being created more than once in Class C, would it be more economical to invoke the constructors everytime and initialize the members, even if we dont need them to be initialized; or just call a method once and pass the object references to initialize them once?
The IL clearly showed how a simple initialization like string.Empty is costly to refer to the Empty member of the system.string. Why do it twice? why not do it just once in a method call and avoid the redundancy?
Agreed there is a cost to make the call to the constructor and the method, but what about the cost of redundancy by calling the class ctor but not using that object any further.
Pass the object to a method that initializes/constructs it when it is needed.
Vision is the ability to see the invisible