When to use the Stack collection in C#?

后端 未结 12 2286
滥情空心
滥情空心 2021-02-14 20:44

I do understand how Stack() and Stack works, but I really can\'t see any scenarios where an array, List or IEnumer

12条回答
  •  青春惊慌失措
    2021-02-14 20:51

    Depth first tree traversal. As opposed to a queue, for breadth first tree traversal.


    Managing presenting different screens to a user as they navigate around them. Showing a screen pushes it to the stack, going 'back' pops it. Draw the top screen.


    When you want a collection where you can add things and always know when you get something out it's the most recently added.


    Implementing Undo/Redo functionality.

提交回复
热议问题