Which Generic is suitable to retrieve a Custom DataType in the reverse order from how they were entered? [closed]
Want to improve this question? Add deta开发者_如何学Goils and clarify the problem by editing this post.
Closed 8 years ago.
Improve this questionI use Asp.net 4 and C#, Linq and EF 4.
I need to retrieve in the reverse order how how they were entered instances for a Custom DataType (in my case CmsCategory).
The collection will contain maximum 10 items.
Which System.Collections.Generic
fits in this situation?
You should use the generic Stack:
var stack = new Stack<int>();
stack.Push(1);
stack.Push(2);
stack.Push(3);
stack.Pop(); // 3
stack.Pop(); // 2
stack.Pop(); // 1
Or just use a simple List and then call Reverse():
var list = new List<int> {1, 2, 3};
list.Reverse(); // {3, 2, 1}
精彩评论