c# - Accessing objects from within the scope of a using block through the object being used -


i'd know if possible following:

        using (myclass o = new myclass())         {             theclassiwantmyclasstosee x = new theclassiwantmyclasstosee();             x.dostuff();         } 

i'd create class (myclass) , use in using block. inside block, want work objects of type (theclassiwantmyclasstosee). when using block falls out of scope, want perform actions on these (theclassiwantmyclasstosee) objects.

is possible make class aware of other objects declared in scope transparently?

i realise add object instances myclass object, i'd make easier developers working api i'm building.

any ideas welcome.

thanks.

the way make myclass aware of theclassiwantmyclasstosee creating reference 1 other. there no way navigate , explore classes in scope. statement true regardless of whether scope relates using block, method block, foreach loop or other.

why not have simple myclass.addrelationship(theclassiwantmyclasstosee child) method makes class aware of other?


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -