A
almurph
Hi everyone,
Hope I'm in the right forum. Apologies if I'm not but I have a
hybrid problem here between classic C and C#.
Is it possible to write the equivalent C code (that uses pointers and
arrays) in C#...
***** BEGIN DIFFICULT C STUFF ******
register double Total=0.0, *A, *B;
int lower;
int upper;
for (A = SomeArray[lower], LWt = SomeArray[upper] ; A <= B; )
{
Total+= *B++;
}
return Sum;
***** END DIFFICULT C STUFF *****
I'm not too worried by the "register" keyword. It's the
pointers and
array combo that C# has problems with. I am trying stuff like:
*** BEGIN SOME C# BUGGY EFFORT ***
unsafe
{
fixed (double* A = &SomeArray[lower])
{
fixed (double* B = &SomeArray[Upper])
{
for (A, B; A <= B
{
//Error here, it says "Only
assignment, call, increment,
decrement, and new object expressions //can
be used as a statement
}
}
}
}
*** END SOME C# BUGGY EFFORT ***
I would appreciate if anyone could offer any comments/
suggestions/
code-samples/help/ideas - would greatly appreciate any assistance in
this regard.
Thanks & cheers,
Al.
Hope I'm in the right forum. Apologies if I'm not but I have a
hybrid problem here between classic C and C#.
Is it possible to write the equivalent C code (that uses pointers and
arrays) in C#...
***** BEGIN DIFFICULT C STUFF ******
register double Total=0.0, *A, *B;
int lower;
int upper;
for (A = SomeArray[lower], LWt = SomeArray[upper] ; A <= B; )
{
Total+= *B++;
}
return Sum;
***** END DIFFICULT C STUFF *****
I'm not too worried by the "register" keyword. It's the
pointers and
array combo that C# has problems with. I am trying stuff like:
*** BEGIN SOME C# BUGGY EFFORT ***
unsafe
{
fixed (double* A = &SomeArray[lower])
{
fixed (double* B = &SomeArray[Upper])
{
for (A, B; A <= B
{
//Error here, it says "Only
assignment, call, increment,
decrement, and new object expressions //can
be used as a statement
}
}
}
}
*** END SOME C# BUGGY EFFORT ***
I would appreciate if anyone could offer any comments/
suggestions/
code-samples/help/ideas - would greatly appreciate any assistance in
this regard.
Thanks & cheers,
Al.