Thursday, July 9, 2009

How do you use pointers in C#?

I want to have a list of items where an item points to the next item.

How do you use pointers in C#?
Sorry, C# doesn't support pointers. You probably need to use the List collection. I havn't used it so I'm not sure. But I do know the pointers where one of the main features removed from C#.
Reply:You don't need a pointer to do this, only a reference (which works the same way.)





Define a class


Add an instance variable nextItem of the same type as the class.


You can then tell each class what the next item in the structure is. You can also have a prevIitem variable to get a double-linked list.

sweet pea

No comments:

Post a Comment