A stack variable declaration needs to meet the following requirements:
- The Stack keyword, its element type between left and right arrow characters, and a unique name
- The new keyword to initialize the stack in memory, followed by the Stack keyword and element type between arrow characters
- A pair of parentheses capped off by a semicolon
In blueprint form, it looks like this:
Stack<elementType> name = new Stack<elementType>();
Unlike the other collection types you've worked with, stacks can't be initialized with elements when they're created.
C# supports a non-generic version of the Stack type that doesn't require you to define the type of element in the stack:
Stack myStack = new Stack();
However, this is less safe and more costly than using the preceding generic version. You can read more about Microsoft's recommendation at https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md.
Stack myStack = new Stack();
However, this is less safe and more costly than using the preceding generic version. You can read more about Microsoft's recommendation at https://github.com/dotnet/platform-compat/blob/master/docs/DE0006.md.
Your next task is to...