c# memory managment help pleaseeee

Associate
Joined
12 Mar 2005
Posts
2,021
Location
Scotland
Hi,

For uni we have go some c# memory mangment cw to do. though i have got stuck at a point. ill try to explane:

Some of the code we have to work with:
Code:
   // computes the board positions achieved by 1 more move
   public Board[] NextPositions () {
      Counter nextCounter;
      Board[] nextPositions;
      int     nextBoardPos = 0;

      if ((NumberOfCounters % 2) == 0)
           nextCounter = Counter.X;
      else nextCounter = Counter.O;

      nextPositions = new Board[9-NumberOfCounters];

      for (int row=0; row<3; row++)
         for (int col=0; col<3; col++)
            if (Position[row,col] == Counter.None) {
               nextPositions[nextBoardPos] = new Board (this, row, col, nextCounter);
               ++nextBoardPos;
               int x=0;
               x++;
               Console.WriteLine (x);
            }

      return nextPositions;
   } // end NextPositions method

Now we ahve to discribe the memory mangment of this section in terms of stack and heap.

Dose nextPositions go on the stack when its declaired at the start or dose it only go on the stack + heap when (nextPositions = new Board...)


Any help would be great!


Thanks
 
btt i guess this would apply to any OOP, so even if u dont know c' i think it has the same mm structure.
 
happytechie said:
would you like us to just write your homework for you or do you have a specific question?

The stack and heap behavior in the .net runtime are well documented at msdn.Microsoft.com

Paul

TheCrow said:
Dose nextPositions go on the stack when its declaired at the start or dose it only go on the stack + heap when (nextPositions = new Board...)

I dont really think that is asking you to do my work for me?? I also thought it was quite specific. No?
 
Back
Top Bottom