Also, the only difference between a struct and a class is that a struct is used for value types, not datatypes, System.Int32 for example is a struct, string is a class.
On Mon, Dec 15, 2008 at 4:11 PM, Brandon Betances <[email protected]>wrote: > C# performs garbage collection automatically, but you can call it > expilictly with the System.GC.Collect() method. > put it where the delete statement is. > > > On Mon, Dec 15, 2008 at 3:18 PM, Alon K <[email protected]> wrote: > >> >> 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 >> > >
