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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:51:19+00:00 2026-05-22T02:51:19+00:00

For an XNA engine I’m trying to make myself, I want an array/arraylist of

  • 0

For an XNA engine I’m trying to make myself, I want an array/arraylist of instances that server as my game objects. If all of my game objects are parented to a GameObject class, what’s a way I can do 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-05-22T02:51:19+00:00Added an answer on May 22, 2026 at 2:51 am

    How about

    GameObject[] gameObjects = new GameObjects[100];
    GameObject[0] = new GameObject();
    GameObject[1] = new GameObject();
    GameObject firstGameObject = gameObjects[0];
    

    or

    List<GameObject> gameObjects = new List<GameObjects>();
    gameObjects.Add(new GameObject());
    gameObjects.Add(new GameObject());
    GameObject firstGameObject = gameObjects[0];
    

    The first will allocate an array with 100 elements and assign the value of the first two elements. The second will create a list where two elements are added.

    The <> indicates that List<> is a generic type where you can specify the type of the element stored in the list. This creates a strongly typed collection.

    Compare that to using an ArrayList:

    ArrayList gameObjects = new ArrayList();
    gameObjects.Add(new GameObject());
    gameObjects.Add(new GameObject());
    GameObject firstGameObject = (GameObject) gameObjects[0];
    

    The ArrayList class stores Object references and to access an item in the list you have to perform a cast. That is both tedious and error prone and you should always use List<> and not ArrayList unless you are developing .NET 1 code.

    To learn more about generics you can study the C# programming guide on generics on MSDN.

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

Sidebar

Related Questions

I am currently developing a C# .net xna game engine. I have been trying
I am writing simple hex engine for action-rpg in XNA 3.1. I want to
Let’s say that I have two C# applications - game.exe (XNA, needs to support
I'm using XNA and creating a bunch of forms that roll their own 'game
I am using XNA 3.1 to develop a small game and I want to
I Am working on a 2D game in XNA that needs some physics. I
I am trying to get involved in XNA game development (most likely for Windows
I'm using VS2010 express to create a game built with xna . I'm trying
I have develop an XNA game on computer 1. When I send it to
I was trying to solve my XNA Font problem , when I found this

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.