recursive without pointer ?

  • Thread starter Thread starter tony
  • Start date Start date
T

tony

here are C++ Codes

class Row
{
//something...
}

Row MyRows[5];

void NextNum(Row * PointOfRows)
{
//do something...
if(something)
{ //do something...
PointOfRows++;
NextNum(PointOfRows);
}
}

Main()
{
NextNum(MyRows);
}

how to achieve it in C# ?
 
Something like this will work just fine:
//**************************
class Row
{
//something...
}

Row MyRows[5];

int rowIndex;

void NextNum( )
{
Row currentRow = MyRows[ rowIndex ];
//do something...
if(something)
{
//do something...
rowIndex++;
NextNum( );
}
}

Main()
{
rowIndex = 0;
NextNum( );
}

//**************************
Chris A.R.
 
It works!

Thank u very much!
Chris A. R. said:
Something like this will work just fine:
//**************************
class Row
{
//something...
}

Row MyRows[5];

int rowIndex;

void NextNum( )
{
Row currentRow = MyRows[ rowIndex ];
//do something...
if(something)
{
//do something...
rowIndex++;
NextNum( );
}
}

Main()
{
rowIndex = 0;
NextNum( );
}

//**************************
Chris A.R.

tony said:
here are C++ Codes

class Row
{
//something...
}

Row MyRows[5];

void NextNum(Row * PointOfRows)
{
//do something...
if(something)
{ //do something...
PointOfRows++;
NextNum(PointOfRows);
}
}

Main()
{
NextNum(MyRows);
}

how to achieve it in C# ?
 
Hi tony
it will look something like that
class Row
{
//something...
}

Row[] MyRows = new Row[5];

void NextNum(Row [] PointOfRows)
{
//do something...
if(something)
{ //do something...

NextNum(PointOfRows);
}
}

Main()
{
NextNum(MyRows);
}
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
Back
Top