Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions code.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections;


public class Stack {

// Old Code:
// ArrayList stack = new();

// Corrected Code:
ArrayList stack = new ArrayList();

public Stack() {}

public void Push(int n)
{
stack.Add(n);
}

public int Pop()
{
if (Size() > 0)
{
int ele = (int)stack[stack.Count-1];
stack.RemoveAt(stack.Count-1);
return ele;
}
return -1;
}

public int Size()
{
return stack.Count;
}
}


// Add this to allow compilation and execution
class Program {
public static void Main(string[] args) {
}
}