本文整理汇总了C#中ArrayStack类的典型用法代码示例。如果您正苦于以下问题:C#ArrayStack类的具体用法?C#ArrayStack怎么用?C#ArrayStack使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:PushAndPop_StackWith1000Elemnts_ShouldTestTheAutoGrowFunctionality
publicvoidPushAndPop_StackWith1000Elemnts_ShouldTestTheAutoGrowFunctionality()
{
//Arrange
varstack=newArrayStack
();
inti=0;
//Assert
Assert.AreEqual(0,stack.Count);
while(i!=1000)
{
//Act
i++;
stack.Push(i.ToString());
//Assert
Assert.AreEqual(i,stack.Count);
}
while(i!=0)
{
//Act
i--;
stringlastElement=stack.Pop();
//Assert
Assert.AreEqual(i,stack.Count);
Assert.AreEqual((i+1).ToString(),lastElement);
}
}
原文链接:http://www.jxszl.com/biancheng/C/556576.html