Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7596493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:55:47+00:00 2026-05-30T21:55:47+00:00

I added a console in my game, in which I can type commands, and

  • 0

I added a “console” in my game, in which I can type commands, and receive a response (it’s based on this). I need to be able to access objects that I instantiate in my Game.cs in my console class. I can’t pass them to the constructor, since I don’t know how much there will be once the “engine” is done.

I tried using a method to add the objects to a Dictionnary<string, object> but I can’t access the properties.

What I’d like to be able to do:

Game1.cs

TileMap tileMap = new TileMap();
BakuConsole console;

...

console = new BakuConsole(this, Content.Load<SpriteFont>("ConsoleFont"));
console.AddRef("tileMap", tileMap);

BakuConsole.cs

public void AddRef(/* some args */) {
   // halp!
}

public void Execute(string input) {
    switch (input)
    {
        case "some --command":
            console.WriteLine(g.ToString());
            // execute stuff, with an object that was added via AddRef()
            console.WriteLine("");
            console.Prompt(prompt, Execute);
            break;
        default:
            console.WriteLine("> " + input + " is not a valid command.");
            console.WriteLine("");
            console.Prompt(prompt, Execute);
            break;
    }
}

I hope I am clear enough. Thanks!

Edit:
I just don’t want my constructor to grow too big in case I add more types:

TileMap tileMap = new TileMap();
OtherType1 ot1 = new OtherType1();
OtherType2 ot2 = new OtherType2();
OtherType3 ot3 = new OtherType3();
OtherType4 ot4 = new OtherType4();
OtherType5 ot5 = new OtherType5();

IronPython does exactly what I want to do, and does it via Globals.Add(“string”, object”). However, I can’t seem to find it in the source (of IronPython).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:55:48+00:00Added an answer on May 30, 2026 at 9:55 pm

    From what you described, you don’t actually need a dictionary, you need several properties on some object, probably directly on BakuConsole;

    class BakuConsole
    {
        … // your current code here
    
        public TileMap TileMap { get; set; }
        public OtherType1 OtherType1 { get; set; }
        …
    }
    

    Then, you can set it like this:

    console.TileMap = tileMap;
    console.OtherType1 = otherType1;
    …
    

    And then when you use it, you won’t have any problems with accessing properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've got a ServiceReference added to a C# Console Application which calls a
Let’s say I have a library, in which I added a few Console.WriteLine(..) statements
I added swipeleft and swiperight listeners this way $(#slides li).swipeleft(function(){ console.log(!!!! swipe left); });
I'm writing a console application in Visual Basic 2008 Express. I added several text
I have a console project that I have been working on. I added log4net
ADDED: This question is now, I believe, subsumed by this one: Using GNU Screen
I added some custom fields (public booleans) to the global class in global.asax.cs which
I made a new project in XCode (console application). Then I added a new
I'm trying to make my first game, a console tetris. I have a class
I'm writing a console application which is looking up information about SSIS packages in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.