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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:08:01+00:00 2026-06-07T05:08:01+00:00

I am trying to create 2D vector2 arrays in XNA,C#. I used the following

  • 0

I am trying to create 2D vector2 arrays in XNA,C#.

I used the following statement:

Vector2[][] SpritePosition=new Vector2[4][];  

Then I used the following for loop to initialize them:

for(i=0;i<4;i++)  
{  
    for(j=0;j<4;j++)  
    {  
    }  
}

However, when I used the for loop, as stated above, it gave me an error, actually two:

  1. Int is a field and used as a type.
  2. ‘for’ is an invalid token in class, struct or interface member declaration.

Can anyone tell why am I facing such a problem?

EDIT: This is the code:

public class Game1 : Microsoft.Xna.Framework.Game
{
    int i=new int();
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    Texture2D texture;
    //Vector2[,] SpritePosition = new Vector2[4,4];
    Vector2[,] SpriteSpeed = new Vector2[4,4];
    for(i=0;i<4;i++)
    {
    }
}
  • 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-07T05:08:03+00:00Added an answer on June 7, 2026 at 5:08 am

    Seems you need to read up on some C# Tutorials

    You are going to need a function for that as so,

    void LoadArray()
    {
    for(int i=0;i<4;i++)  
    {  
        for(int j=0;j<4;j++)  
        {  
    SpritePosition[i,j] = new Vector2(i,j)
        }  
    }
    

    You can call it from your initialize method, using LoadArray()

    }

    Also, You dont need int i = new Int() for basic stuff like strings, ints, etc you dont need the new Whatever() part

    Just do

    for(int i=0;i<4;i++)
    {
    }

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

Sidebar

Related Questions

Trying to create a new Dedicated Cache Role in Windows Azure but get the
I am trying to create a Vector2 class. When I try to type vec1
I'm trying to create a vector from an array of doubles. I then want
I am trying to create a somewhat generic xna physics module like this: class
I am trying to create a char array dynamically. However, do not matter which
I'm trying to create a sparse vector class in C++, like so: template<typename V,
I'm trying to create a function that would append two vectors together, but I
So, im trying to create a 3 dimensional 5x3x2 vector, using the vector lib
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying create a delegate representation of constructor by emitting a Dynamic Method,

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.