相当于C#中的C结构

时间:2011-03-19 18:00:34

标签: c# c++ c visual-studio struct

有人可以帮我解决C#中等效的C代码吗?

struct { int left, right; } stack[MAX];

谢谢!

2 个答案:

答案 0 :(得分:8)

public struct PickAName
{
     public int left;
     public int right;
}

private const int MAX = 666;
PickAName[] stack = new PickAName[MAX];

或:

Stack<PickAName> stack = new Stack<PickAName>();

答案 1 :(得分:3)

public struct PickAName
{
     public int left;
     public int right;
}

不确定[MAX]是什么堆栈。

如果要以伪代码术语使用“堆栈”,请执行:

Stack<PickAName> stack = new Stack<PickAName>();
stack.Push(new PickAName());
stack.Pop();