I have some C code I am trying to translate into C# code and I’m running into pointers which I am not familiar with so I don’t know the C# equivalent. Get I get some help?
Case 1: Given these three lines in C, how do I declare p in C#?
double snorm[169];
double *p = snorm;
*p = 1.0;
Case 2: I have no idea what the pointers are actualy doing so I don’t know how to change this line to C#.
*(snorm+n) = *(snorm+n-1) * (double)(2*n-1) / (double)n;
First:
Than just use
snorminstead ofp.Second:
Basically
*pmeans that you take the value at the address of memory, referenced byp. Incrementing and adding to the pointer are moving the pointer in memory, sop++, as well as(p+1)just refers to the next item in memory (how far it really moves in memory depends on the data type the pointer points to). And,*(p+n)is just a value of the n-th item in the array (ifppoints to an array)Anyway, you should get yourself familiar with pointers.