stack.pop()方法_C.示例中的Stack.Pop()方法
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                stack.pop()方法_C.示例中的Stack.Pop()方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.                        
                                stack.pop()方法
C#Stack.Pop()方法 (C# Stack.Pop() method)
Stack.Pop() method is used to remove an object from the top of the stack. The method removes and returns the object from the top.
Stack.Pop()方法用于從堆棧頂部刪除對象。 該方法從頂部刪除并返回對象。
Syntax:
句法:
Object Stack.Pop();Parameters: None
參數:無
Return value: Object – it returns the items to be removed from the top.
返回值: Object –返回從頂部刪除的項目。
Example:
例:
declare and initialize a stack:Stack stk = new Stack();insertting elements:stk.Push(100);stk.Push(200);stk.Push(300);stk.Push(400);stk.Push(500);popping stack elements:stk.Pop();stk.Pop();stk.Pop();Output:200 100C#示例使用Stack.Pop()方法從堆棧中刪除對象 (C# example to remove an object from the stack using Stack.Pop() method)
using System; using System.Text; using System.Collections;namespace Test {class Program{//function to print stack elementsstatic void printStack(Stack s){foreach (Object obj in s){Console.Write(obj + " ");}Console.WriteLine();}static void Main(string[] args){//declare and initialize a stackStack stk = new Stack();//insertting elementsstk.Push(100);stk.Push(200);stk.Push(300);stk.Push(400);stk.Push(500);//printing stack elementsConsole.WriteLine("Stack elements before popping are...");printStack(stk);//popping stack elementsobject item = 0;item = stk.Pop();Console.WriteLine(item + " is popped");item = stk.Pop();Console.WriteLine(item + " is popped");item = stk.Pop();Console.WriteLine(item + " is popped");//printing stack elementsConsole.WriteLine("Stack elements after popping are...");printStack(stk);//hit ENTER to exitConsole.ReadLine();}} }Output
輸出量
Stack elements before popping are... 500 400 300 200 100 500 is popped 400 is popped 300 is popped Stack elements after popping are... 200 100Reference: Stack.Pop Method
參考: Stack.Pop方法
翻譯自: https://www.includehelp.com/dot-net/stack-pop-method-with-example-in-c-sharp.aspx
stack.pop()方法
總結
以上是生活随笔為你收集整理的stack.pop()方法_C.示例中的Stack.Pop()方法的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 微信小程序 查找兄弟节点_使用C ++程
- 下一篇: 联想一体机电脑处理器i35005u和i3
