c# - Instantiating a class with outside accessiblity from a method/event -
i have class game
cannot made static serialization purposes. instantiate game
method , have new instance accessible elsewhere in code.
if try this:
public void btnnewgame_click(object sender, eventargs e) { game game = new game(); }
the new instance unusable outside of method. there way instantiate game
within method , have instance accessible elsewhere? or there workarounds? thing don't want game
instantiated before button clicked.
any advice appreciated.
the singleton pattern lazy instantiation friend here.
check out this answer of mine example.
Comments
Post a Comment