I'm using Visual C# to program an RPN calculator using Stack. Problem is I don't know how to do this. I'm using System.Collections.Generic, but
我正在使用Visual C#使用Stack编程RPN计算器。问题是我不知道该怎么做。我正在使用System.Collections.Generic,但是
Stack<double> s = new Stack<double>();
generates the error:
生成错误:
Using the generic type 'System.Collections.Generic.Stack' requires '1' type arguments
使用泛型类型'System.Collections.Generic.Stack'需要'1'类型参数
I'm pretty clueless here. Thanks for the help.
我在这里很无能为力。谢谢您的帮助。
2 个解决方案
#1
Try this
Stack<int> s = new Stack<int>();
Replace int with whatever type you are storing in the stack.
将int替换为您在堆栈中存储的任何类型。
#2
You need to specify the type of the elements that you will store on your stack, for example a stack of integers:
您需要指定要存储在堆栈中的元素的类型,例如一堆整数:
Stack<int> s = new Stack<int>();
#1
Try this
Stack<int> s = new Stack<int>();
Replace int with whatever type you are storing in the stack.
将int替换为您在堆栈中存储的任何类型。
#2
You need to specify the type of the elements that you will store on your stack, for example a stack of integers:
您需要指定要存储在堆栈中的元素的类型,例如一堆整数:
Stack<int> s = new Stack<int>();