How can I create objects that are "public" to an entire application? RRS feed

  • Question

  • User1216900827 posted
    I think I'm still a little confused about Classes and Objects.

    I am creating a small game, to teach myself programming. It's kind of like a Pokemon card game, with different characters, monsters etc.

    I want to use a HERO Class to store all the info on the players and a MONSTER class to store all info on Monsters. But... I am having all kinds of trouble with the idea of allowing these objects be present no matter what form or module I am dealing with.

    So if I have an Object named "Superman" and it's got these kinds of properties :

    superman.name = "Superman"
    superman.health ="100"
    superman.speed ="100"
    superman.inventory1 ="backpack"

    and a monster might look like this

    goblin.name = "goblin"
    goblin.health ="22"
    goblin.speed ="50"
    goblin.inventory1 ="axe"

    I guess my question is.... how can I create the SUPERMAN object, from the HERO CLASS so that I can "publicly" use it no matter what FORM or MODULE I am in?

    Right now, it seems I can only Create and Use the Object in 1 place at a time.

    I'm confused at to how this is supposed to work, please help!!
    <!-- / message -->
    <!-- controls -->
    Sunday, September 14, 2008 3:02 PM

All replies

  • User56700650 posted

    You can put the object into Session or Application.
    You can easily access these classes in your app as well as class libraries (ie. HttpContext.Current.Session )

    Sunday, September 14, 2008 7:46 PM
  • User1216900827 posted

    I know I posted this in the ASP.NET forum,  but I am more looking for help with this problem, in VB.NET,  which is why I posted it in the VB section.

    Sorry for the misunderstanding.

    I believe your advice is more relevant to ASP.NET. 


    Wednesday, September 17, 2008 2:49 PM
  • User-990694832 posted

    Try inheritance

    class hero


    end class

    class superman

    inherits hero

    end class

    so inside the superman class all of the hero method can be called

    Hope this helps


    Wednesday, September 17, 2008 3:29 PM