diff --git a/code.cs b/code.cs new file mode 100644 index 0000000..6ad59a8 --- /dev/null +++ b/code.cs @@ -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) { + } +} \ No newline at end of file