double[] firstVal;
int secondVal;
double thirdVal;
int fourthVal;
// secondVal, thirdVal and fourthVal must be set before the following lines,
otherwise the C# compiler will reject them.
firstVal = new double[secondVal];
// C++ version of following line would also benefit from the rewriting
below!
firstVal[(int)thirdVal] = fourthVal;
// no need to delete array, GC does it!
Morale: C# just forces you to write something that make sense (from a type
checking standpoint). You can forget about ugly pointer hacks (like
*(firstVal + thirdVal) -- does C++ really accept this without barking, seems
to me that an (int) cast would be necessary on thirdVal)
Bruno.
"C# newcomer" <an*******@discussions.microsoft.com> a écrit dans le message
de news:6e****************************@phx.gbl...
Hi all
Please help me with the C# equivalent syntax for the
following C++ code. Thanks a lot in advance.
double *firstVal;
int secondVal;
double thirdVal;
int fourthVal;
firstVal = new double[secondVal];
*(firstVal + thirdVal) = fourthVal;
delete [] firstVal;