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 8226593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:49:28+00:00 2026-06-07T15:49:28+00:00

I am having problems with retrieving a texture2D from a listDictionary. This is my

  • 0

I am having problems with retrieving a texture2D from a listDictionary.

This is my LoadGraphics Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Media;

namespace Space_Game
{
    public static class LoadGraphics
    {
        //global variable
        public static ListDictionary _blue_turret_hull;

        public static void LoadContent(ContentManager contentManager)
        {
            //loads all the graphics/sprites
            _blue_turret_hull = new ListDictionary();
            _blue_turret_hull.Add("graphic", contentManager.Load<Texture2D>("Graphics/Team Blue/Turret hull spritesheet"));
            _blue_turret_hull.Add("rows", 1);
            _blue_turret_hull.Add("columns", 11);
        }
    }
}

This is the Turret class the should retrieve the Texture2D:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Space_Game
{
    class Turret_hull:GameObject
    {
        public Turret_hull(Game game, String team)
            : base(game)
        {
            if(team == "blue") { _texture = LoadGraphics._blue_turret_hull["graphic"];      }
        }
    }
}

Only here it gives the following error:

Cannot implicitly convert type ‘object’ to ‘Microsoft.Xna.Framework.Graphics.Texture2D’. An explicit conversion exists (are you missing a cast?)

I know there is a problem regarding the fact that I stored it in a listDictionary. I did that, because that way I could retrieve all necessary info at once. How else should I do this?

Thanks in Advance,

Mark Dijkema

  • 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-06-07T15:49:31+00:00Added an answer on June 7, 2026 at 3:49 pm

    Probably a better way to achieve what you want is to define a new class with 3 properties and use this to retrieve the info you need to pass around:

    public class TurretHullInfo
    {
        Texture2D Graphic { get; set; }
        int Rows { get; set; }
        int Columns { get; set; }
    }
    
    public static class LoadGraphics
    {
        //global variable
        public static TurretHullInfo _blue_turret_hull;
    
        public static void LoadContent(ContentManager contentManager)
        {
            //loads all the graphics/sprites
            _blue_turret_hull = new TurretHull();
            _blue_turret_hull.Graphic = contentManager.Load<Texture2D>("Graphics/Team Blue/Turret hull spritesheet");
            _blue_turret_hull.Rows = 1;
            _blue_turret_hull.Columns = 11;
        }
    }
    
    class Turret_hull : GameObject
    {
        public Turret_hull(Game game, String team)
            : base(game)
        {
            if(team == "blue")
                _texture = LoadGraphics._blue_turret_hull.Graphic;     
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems with retrieving multiple instances of a session variable from an InProc
Having a problem retrieving a list of items from the database. This is what
Im having problems retrieving a field from my ms-access database. The table name is
I'm having problems retrieving the time from a date field in a SP. If
I'm having problems retrieving the route url from controller.RouteUrl(routeName) method. Here is my code
For some reason I'm having a problem retrieving data from my database. It leaves
Im having problems with a method in a class file: public static function getPageLeft($pid)
I am having problems retrieving accurate data values with my stored proc query below:
I am having a problem while retrieving data from an ArrayList and displaying them
I'm having a problem with retrieving information from a MySQL Table with PHP. I

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.