tags:

views:

40

answers:

1

I am looking for a method to share resources among siblings. For example, if the parent class has a File handler, is there a way in which I need to open and close a file only once.

Seems like a simple problem but I can't figure it out. I know I can pass the resources as parameters but is there a more elegant way ?

+3  A: 

You could have the file handler be a static variable within the parent class. Than when you call the parent constructor of the the class, you would get the current instance of the file handler.

Read more about static classes and static members here http://msdn.microsoft.com/en-us/library/79b3xss3%28VS.80%29.aspx

Scott