From 10d6d059e8089f570b7ec01bf120689a164958c2 Mon Sep 17 00:00:00 2001 From: Base-2 Date: Thu, 12 Mar 2026 14:24:51 +0200 Subject: [PATCH 1/2] DS&A-Beginners Fix c-sharp lecture code --- code.cs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 code.cs diff --git a/code.cs b/code.cs new file mode 100644 index 0000000..8741095 --- /dev/null +++ b/code.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections; + + +public class Stack { + 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; + } +} + +class Program { + public static void Main(string[] args) { + } +} \ No newline at end of file From 62270b090b7e86c73c24aa1b52bc158d59b441a3 Mon Sep 17 00:00:00 2001 From: Base-2 Date: Thu, 12 Mar 2026 14:28:56 +0200 Subject: [PATCH 2/2] DS&A-Beginners-Stacks Fix c-sharp lecture code --- code.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code.cs b/code.cs index 8741095..6ad59a8 100644 --- a/code.cs +++ b/code.cs @@ -3,6 +3,11 @@ public class Stack { + + // Old Code: + // ArrayList stack = new(); + + // Corrected Code: ArrayList stack = new ArrayList(); public Stack() {} @@ -29,6 +34,8 @@ public int Size() } } + +// Add this to allow compilation and execution class Program { public static void Main(string[] args) { }