C++ equivalent in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
Best way to implement the following in C#.
C++ Code:
ClassOne {int a;}
ClassTwo{int b; ClassTwo *pClassTwo;}
I can do the above in C# by using ArrayList as fallows:
ClassTwo{int b; ArrayList objClassTwoList;}
But is there any performance penalty in coding this way or else is there any better way to achieve this.
Please help!!
Thanx in advance.
 
You could use ArrayList collection, or you could use a normal array if
you know the size before hand. There is no other way to do this as
far as I know. I assume that pClassTwo is a pointer to a series of
objects, and not just one.

--
Louis Marascio
louis at no spam dot louismarascio dot com



faktujaa said:
Hi All,
Best way to implement the following in C#.
C++ Code:
ClassOne {int a;}
ClassTwo{int b; ClassTwo *pClassTwo;}
I can do the above in C# by using ArrayList as fallows:
ClassTwo{int b; ArrayList objClassTwoList;}
But is there any performance penalty in coding this way or else is
there any better way to achieve this.
 
faktujaa said:
Hi All,
Best way to implement the following in C#.
C++ Code:
ClassOne {int a;}
ClassTwo{int b; ClassTwo *pClassTwo;}
I can do the above in C# by using ArrayList as fallows:
ClassTwo{int b; ArrayList objClassTwoList;}
But is there any performance penalty in coding this way or else is
there any better way to achieve this. Please help!!
Thanx in advance.

The C# equivilent is:

class ClassTwo
{
int b;
ClassTwo pClassTwo;
}

In C#, variables of a type derived from object are really just pointers that
you access with . instead of ->

- Pete
 
Back
Top