我advanced collections在书中学到了一些等等,并且遇到了stacks.我得到了概念,但想制作一个快速程序,从defined point in the stack当时删除一个项目places all the values back onto the stack.我在这里有我的代码,但我得到System.InvalidOperationException类型的异常,其中堆栈的其他信息为空.我似乎无法理解; 有人可以帮忙吗?
这是我的代码:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StackRemover
{
class Program
{
static void Main(string[] args)
{
int index = 0; //the index they want to remove
Stack[] array = new Stack[1]; // will hold the array returned by remove()
Stack stack = new Stack();
//fill the stack with values from …Run Code Online (Sandbox Code Playgroud)