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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:29:42+00:00 2026-06-08T19:29:42+00:00

Well, it’s hard to explain it in words. So here’s an example. In the

  • 0

Well, it’s hard to explain it in words. So here’s an example. In the SDL .NET API, there’s a class called SpriteCollection which is designed to be, well… a collection of sprites. However the problem is that for some reason the developers decided to not make SpriteCollection generic, like the .NET List<> class. So, I guess, it can only work with the Sprite class or other classes that inherit from Sprite? Anyway, let’s say I derive Tile from Sprite. And I add two new properties to it:

class Tile : Sprite
{

    public Tile(char symbol = default(char), bool solid = true)
    {
        Symbol = symbol;
        Solid = solid;
    }

    public char Symbol
    {
        get;
        set;
    }

    public bool Solid
    {
        get;
        set;
    }
}

Now, how can I use the SpriteCollection with Tiles and still be able to use the Tile exclusive properties like Solid?

One (probably stupid) solution would perhaps be this:

Tile t = (Tile) myCollection[i];
if (t.Solid) { ... }

Is there any better way to do something like this?

  • 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-08T19:29:45+00:00Added an answer on June 8, 2026 at 7:29 pm

    Your proposal to cast the return values of the SpriteCollection to Tile is the way to do it. You do not have better options if you need to use the collection class provided and cannot change it.

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

Sidebar

Related Questions

Well, I have a application which somehow requires some system resources, but how do
well there are 3 activities say Act1 , Act2 and Act3 . in Act1
Well, I am storing variables inside of a class that will be used for
Well im here because i have a problem. i have code that was created
Well, this is an interesting problem. I have an ASP.NET MVC3 Intranet application running
Well, I know there is a lots of posts about it, but I have
Well, I have to revive a question that was answered here before. I've made
Well, i saw a Qt Quick Image's Carousel Example in h ttp://developer.qt.nokia.com/wiki/Qt_Quick_Carousel . I
Well, I got problem here with opengl ES stuff (just started to learn about
Well, here's what I have to do. I need to trim the whitespaces 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.