1. Course
  2. Generic collections
  3. Stack with arrays

Stack with arrays

Last updated: 8/23/2020 Difficulty: Intermediate

Create a C# program that simulates the operation of a stack using an array of integers. There will be a class called Stack with 2 properties, an array of integers and an integer to store the current position of the stack.

The stack must have a constructor where the size will be specified per parameter and two methods, one for Push() and one for Pop() the values. Remember that the new values are queued at the beginning of the stack and the last ones are unstacked.

To test, create a Stack object in the program's Main and try to stack and unstack some values.






Generic collections

4 / 5

Android App

Practice C# anywhere with the free app for Android devices.

Android App

Exercises C# by difficulty

Learn C# at your own pace, the exercises are ordered by difficulty.