176
1
using System; using System.Diagnostics;
2
3
namespace FixedLengthStackImplementationofStackofStringsArray
4
{
5
internal class Stack
6
{
7
static readonly int MAX = 1000; //Max number of elements in string[] array
8
int count;
9
10
string[] stack = new string[MAX];
11
12
public Stack() //constructor
13
{
14
count = 1000; //initialize stack with how many default values
15
if (count > MAX) count = MAX; //or throw error
16
//values sets max size
17
//stack = new string[] { "x", "y", "z", "w" }; //w is ignored, no error given of MAX is 3
18
}
19
20
public bool IsEmpty()
21
{
22
return (count == 0);
23
}
24
Cached Result