c# - Error while accessing array -


i'm getting error

wrong number of indices inside []; expected 2

near bottom of code. i'm not sure why. i'm trying build set of arrays manipulate i'm getting hung @ point.

public static void main (string[] args) {     initialize ();      while (true) {         systemevents.checkevents ();         update ();         render ();     } }  public static void initialize () {     // set graphics system     graphics = new graphicscontext ();      gen = new random ();     texture2d ptex= new texture2d("application/assets/plane.png",false);     player= new sprite(graphics,ptex);      player.position.x = graphics.screen.rectangle.width / 2 - player.width / 2;     player.position.y = graphics.screen.rectangle.height / 2 - player.height / 2;      xpos = 0;     ypos = 0;      pieces = new texture2d[6];      bg = new sprite[9,12];      pattern = new int[9,12];      (int i=0; i<6; i++)         pieces [i] = new texture2d ("application/assets/island" + + ".png", false);      for(int i=0; i< pattern.length; i++)         pattern[i] = gen.next(0,5);      // problem here 

pattern two-dimensional array. need provide 2 indices access it's values.

if want populate pattern random values can use 2 loops:

for(int = 0; i<pattern.getlength(0); i++)  {      for(int j=0; j<pattern.getlength(1); j++)      {           pattern[i,j] = gen.next(0,5);      } } 

further reading


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -