Tuesday, July 14, 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#?
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.
Reply: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#.

survey for money

No comments:

Post a Comment