开发者

Which Generic is suitable to retrieve a Custom DataType in the reverse order from how they were entered? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add deta开发者_如何学Goils and clarify the problem by editing this post.

Closed 8 years ago.

Improve this question

I 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}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜