I’m trying to create a menu system that allows you to go backward and forward while returning the final selected data to the calling method.
Take for example a orderFood() method displays a menu of choices of types of food that can be ordered. If someone selects seafood a seafood() method would run and query what types of seafood is availble to order then display it
if the user selects fishsticks, fishsticks would be returned to the method that called order food. Likewise, this menu system would allow the user to go back to the previous menu.
I’m thinking (Using C#) I’d have to use reflection and unsafe code (pointers) to get this sort of effect but I am positive that there is a simpler way to do this. Any suggestions?
Thanks, Michael
Instead of thinking about the menus as a stack, try thinking of them like a tree.
If you do this, it should be fairly easy to ‘walk’ up and down the tree as you need to implement your stack approach.
This would be fairly easy to read from a file or database (very easy from XML, in particular), and also shouldn’t be too tough to walk up and down.
There isn’t really anything in this that should require unsafe code or reflection – it can all be done with standard collections in C#.