equivalent of C struct in C#
Could someone help me with what the equivalent of this C code is in C#?
struct { int l开发者_如何学JAVAeft, right; } stack[MAX];
Thanks!
public struct PickAName
{
public int left;
public int right;
}
private const int MAX = 666;
PickAName[] stack = new PickAName[MAX];
or:
Stack<PickAName> stack = new Stack<PickAName>();
public struct PickAName
{
public int left;
public int right;
}
Not sure what stack[MAX] does.
If you want to use a "stack" in pseudocode terms, do:
Stack<PickAName> stack = new Stack<PickAName>();
stack.Push(new PickAName());
stack.Pop();
精彩评论