Hi,

I remember that in C++ one had to issue the following statement (or
something similar) to clean up memory:

delete pNode;

and the memory address assigned to pNode will be unassigned.
Is there something like this that needs to be done in C# ?

So for example I have:

pHold = pIndex;
pIndex = pIndex->pNext;
delete pHold; ????? <-- what can I do here

While on the topic, I have been doing the following to create linked
lists in the intermediate step:

NODE* pCreate = stackalloc NODE[1];
pIndex->pNext = pCreate;
pIndex = pCreate;

While I haven't programmed in C++ in a while I remember that this
could be done directly in C++:

pIndex->(*pNext) = new NODE;
pIndex = pIndex->pNext;

Also the code above using stackalloc NODE[1] just feels wrong and as
if I'm using it to do something it wasn't intended to do. Now for the
application it is important to keep the spirit of a linked list and
not an stacked list, meaning I want to be able to move the links
around dynamically.

How can I do this correctly, I may not be understanding the
fundamentals of C# (such as how variables are treated). Also NODE is a
struct, which is different from a Class in C# in terms of data from my
understanding.

Appreciate your help.

-Alon

Reply via email to