Stack (C#)

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:04 AM on 8/14/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

20 Terms

1
New cards

Stack

A generic collection in System.Collections.Generic that stores elements for last-in, first-out (LIFO) processing. Domain: C# → .NET → System.Collections.Generic → Stack

2
New cards

LIFO

Last In, First Out; the most recently added element in a Stack is the next element removed.

3
New cards

Top of a Stack

The end of a Stack where elements are added, inspected, and removed.

4
New cards

Bottom of a Stack

The end of a Stack containing the elements that have been stored the longest.

5
New cards

new Stack()

Creates an empty Stack.

6
New cards

new Stack(collection)

Creates a Stack containing elements copied from the specified collection.

7
New cards

stack.Count

Gets the number of elements currently contained in the Stack.

8
New cards

stack.Push(item)

Adds an element to the top of the Stack.

9
New cards

stack.Pop()

Removes and returns the element at the top of the Stack; throws InvalidOperationException if the Stack is empty.

10
New cards

stack.Peek()

Returns the element at the top of the Stack without removing it; throws InvalidOperationException if the Stack is empty.

11
New cards

stack.TryPop(out result)

Attempts to remove and return the top element, returning false if the Stack is empty.

12
New cards

stack.TryPeek(out result)

Attempts to return the top element without removing it, returning false if the Stack is empty.

13
New cards

stack.Contains(item)

Determines whether the specified element occurs in the Stack.

14
New cards

stack.Clear()

Removes all elements from the Stack.

15
New cards

stack.ToArray()

Copies the Stack elements into a new array with the top element first.

16
New cards

stack.TrimExcess()

Reduces excess internal storage capacity when appropriate relative to the number of elements currently stored.

17
New cards

Push vs Pop

Push adds an element to the top of a Stack, whereas Pop removes and returns the element from the top.

18
New cards

Pop vs Peek

Pop returns and removes the top element, whereas Peek returns the top element without removing it.

19
New cards

TryPop vs Pop

TryPop safely reports failure when the Stack is empty, whereas Pop throws an InvalidOperationException.

20
New cards

Stack vs Queue

Stack uses LIFO processing, where the newest element leaves first; Queue uses FIFO processing, where the oldest element leaves first.