Difference between Queue and Stack in c#?

Syedshakeer
Posted by Syedshakeer under C# category on | Views : 16617
Queue:-
1)A Queue is a collection where elements are processed in "First in First Out ".
2)The items that is put first in the Queue is read First.
3)Enqueue() method adds an item to the end of the Queue.
4)Dequeue() method reads and removes an item from the head of the Queue.
5)Peek() method reads an item from the head of the Queue but does not remove an item.

Stack:-
1)Stack is a collection where elements are processed in "Last in First Out ":.
2)The items that is added last to the Stack is read First.
3)Push() method adds an item to the Top of the Queue.
4)Pop() method returns an item from the Top of the Stack.
5)Peek() method returns an item from the Top of the Stack but does not remove an item.
6)Structs are Value Type
7)Structs stored in Stack.It does not support Inheritance

Comments or Responses

Login to post response