fork download
  1. class stack1
  2. {
  3. public int[] _array;
  4.  
  5. private const int defaultCapacity = 1;
  6. private int size;
  7. public stack1()
  8. {
  9. this.size = 0;
  10. this._array = new int[defaultCapacity];
  11. }
  12. public bool IsEmpty()
  13. {
  14. return this.size == 0;
  15. }
  16. public virtual int Count
  17. {
  18. get { return this.size; }
  19. }
  20. public int Pop()
  21. {
  22. if (this.size == 0)
  23. throw new InvalidOperationException();
  24. return this._array[--this.size];
  25. }
  26. public void Push(int newElement)
  27. {
  28. if (this.size == this._array.Length)
  29. {
  30. int[] newArray = new int[2 * this._array.Length];
  31. Array.Copy(this._array, 0, newArray, 0, this.size);
  32. this._array = newArray;
  33. }
  34. this._array[this.size++] = newElement;
  35. }
  36. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(23,27): error CS0246: The type or namespace name `InvalidOperationException' could not be found. Are you missing a using directive or an assembly reference?
prog.cs(31,17): error CS0103: The name `Array' does not exist in the current context
Compilation failed: 2 error(s), 0 warnings
stdout
Standard output is empty