44
1
using System;
2
using System.Collections;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
Stack MyStack = new Stack();
9
MyStack.Push(5);
10
MyStack.Push(1);
11
MyStack.Push(2); //last item to be pushed on stack ( means at top)
12
13
//print stack using foreach loop
14
Console.WriteLine("Stack After Pushing items:");
15
PrintStack(MyStack);
16
17
Console.WriteLine();
18
//remove item from stack
19
MyStack.Pop();
20
21
//now check stack again
22
Console.WriteLine("Stack After pop: ");
23
PrintStack(MyStack);
24
Cached Result
Compilation error (line 6, col 0): String constants must end with a double quote.
Compilation error (line 8, col 0): End of statement expected.
Compilation error (line 9, col 0): Expression is not a method.
Compilation error (line 9, col 0): Expression expected.
Compilation error (line 9, col 0): Method arguments must be enclosed in parentheses.
Compilation error (line 10, col 0): End of statement expected.
Compilation error (line 11, col 0): Variable 'marks' hides a variable in an enclosing block.
Compilation error (line 12, col 0): End of statement expected.
Compilation error (line 8, col 0): End of statement expected.
Compilation error (line 9, col 0): Expression is not a method.
Compilation error (line 9, col 0): Expression expected.
Compilation error (line 9, col 0): Method arguments must be enclosed in parentheses.
Compilation error (line 10, col 0): End of statement expected.
Compilation error (line 11, col 0): Variable 'marks' hides a variable in an enclosing block.
Compilation error (line 12, col 0): End of statement expected.