stack示例_C.示例中的Stack.Clone()方法

stack示例

C#Stack.Clone()方法 (C# Stack.Clone() method)

Stack.Clone() method is used to create a shallow copy of the stack.

Stack.Clone()方法用于創建堆棧的淺表副本。

Syntax:

句法:

    Object Stack.Clone();

Parameters: None

參數:

Return value: Object – a shallow copy of the stack.

返回值: 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);
creating clone/copy of the stack:
Stack stk1 = (Stack)stk.Clone();
Output:
stk:  500 400 300 200 100
stk1: 500 400 300 200 100

C#示例使用Stack.Clone()方法創建堆棧的淺表副本 (C# example to create a shallow copy of the stack using Stack.Clone() method)

using System;
using System.Text;
using System.Collections;
namespace Test
{
class Program
{
//function to print stack elements
static void printStack(Stack s)
{
foreach (Object obj in s)
{
Console.Write(obj + " ");
}
Console.WriteLine();
}
static void Main(string[] args)
{
//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);
//printing stack elements
Console.WriteLine("Stack (stk) elements are...");
printStack(stk);
//creating clone/copy of the stack
Stack stk1 = (Stack)stk.Clone();
//printing stack elements
Console.WriteLine("Stack (stk1) elements are...");
printStack(stk1);
//hit ENTER to exit
Console.ReadLine();
}
}
}

Output

輸出量

Stack (stk) elements are...
500 400 300 200 100
Stack (stk1) elements are...
500 400 300 200 100

Reference: Stack.Clone Method

參考: Stack.Clone方法

翻譯自: https://www.includehelp.com/dot-net/stack-clone-method-with-example-in-c-sharp.aspx

stack示例

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541616.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541616.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541616.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

簡述計算機圖形的圖形應用主要有哪些,5計算機圖形學考試簡答題復習.doc

5計算機圖形學考試簡答題復習計算機圖形學考試簡答題復習1、簡述計算機動畫的概念,它經歷了哪幾個階段的發展?(2分)計算機動畫是指采用圖形與圖像的處理技術,借助于編程或動畫制作軟件生成一系列的景物畫面,其中當前幀是前一幀的部…

在圖片中選定任意凸多邊形制作掩膜程序MATLAB

function S get_convex_S(C,vx,vy) %該函數實現的功能為指定圖像中多邊形的頂點,返回屬于該凸多邊形中的所有像素點 %xv,yv為頂點坐標按照順時針或者逆時針。vx(1) xv(end); yv(1) yv(end) %輸入的C是結構,vx vy是數組存的是頂點坐標。 %輸…

js console 輸出到文件_Node.js核心入門

正文核心模塊是Node.js的心臟,主要是有一些精簡高效的庫組成(這方面和Python有很大的相似之處),為Node.js提供了基礎的API。主要內容包括:Node.js核心入門(一)全局對象常用工具事件機制Node.js核心入門(二)文件系統訪問HTTP服務器與客戶端全局…

scala 當前日期_如何在Scala中檢查當前日期和時間?

scala 當前日期Scala is a general-purpose programming language, which is majorly used for data manipulation. It has libraries and support for almost all different utilities that are important. One of the important things that are required while programming …

計算機科學考試大綱,計算機科學與技術考試大綱.doc

計算機科學與技術考試大綱計算機科學與技術專業本專業的專業課程考試為“計算機軟件基礎”和“計算機硬件基礎”兩門課程的組合試卷,卷面總分200分,時間150分鐘,考試方式為筆試。考試可攜帶計數器,但禁止攜帶文曲星、商務通等帶有…

eclipse中項目內存溢出問題

2019獨角獸企業重金招聘Python工程師標準>>> SpringBoot項目熱啟動Perm區內存溢出。 Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method jpaVendorAdapter threw exception; nested exception is java.lang.OutOfMemoryErro…

云盾idaas登陸_移動端掃碼登錄IDaaS平臺

{"moduleinfo":{"card_count":[{"count_phone":1,"count":1}],"search_count":[{"count_phone":10,"count":10}]},"card":[{"des":"刷臉門禁通行系統前端接入人臉AI賦能的人臉…

express rest_Express / Node中用于REST API的郵遞員工具

express restWhen dealing with routes (like in express), we may use any of the REST verbs and at times, the browser is limited to facilitate testing the routes/REST API. 在處理路由時(如快速表達),我們可以使用任何REST動詞,有時瀏覽器會受到…

我們在使用計算機時,不能做什么?,11秋季學期計算機應用技術基礎學習周期_01任務-在線作業[1]1...

1.選購顯示器應優先考慮顯示器的( B )性能指標選A.顯示器的防輻射指標B. 顯示器的帶寬C. 顯示器的刷新率D. 顯示器的尺寸2. 一個聲音文件采用雙聲道8位采樣精度、22K采樣頻率錄音,它的大小是5M,如果采用單聲道16位采樣精度、44K采樣頻率錄音,…

按一個按鈕會隨機死人_《饑荒》那些年坑爹的隨機地圖,最后一個簡直笑死人...

饑荒是一款隨機性很強的游戲,這也是饑荒這款游戲相當耐玩的主要原因。別的不說小編敢保證隨機開圖的話你絕對找不到兩張一模一樣的地圖。地圖上的資源也會大不相同。不管是稀有的各種奇遇還是基礎資源的刷新數量都是完全不同的。當然對于一些基礎資源玩家們并沒有多…

介詞at_介詞邏輯| 離散數學

介詞at介詞或陳述 (Preposition or Statement) A preposition is a definition sentence which is true or false but not both. 介詞是一個定義語句,它是對還是錯,但不能同時包含兩者。 For example: The following 8 sentences, 例如:以下…

職稱計算機提前考試試卷,職稱計算機考試多項選擇考試卷模擬考^試題

《職稱計算機考試多項選擇考試卷模擬考^試題》由會員分享,可在線閱讀,更多相關《職稱計算機考試多項選擇考試卷模擬考^試題(8頁珍藏版)》請在人人文庫網上搜索。1、姓名:________________ 班級:________________ 學號:…

形象易懂講解算法I——小波變換

https://zhuanlan.zhihu.com/p/22450818?referdong5 最早發于回答:能不能通俗的講解下傅立葉分析和小波分析之間的關系? - 咚懂咚懂咚的回答現收入專欄。從傅里葉變換到小波變換,并不是一個完全抽象的東西,可以講得很形象。小波變…

r語言安裝ipsolve_R語言矩陣操作之矩陣運算

1.轉置運算對于矩陣A,函數t(A)表示矩陣A的轉置,如:> Amatrix(1:6,nrow2);> A;[,1] [,2] [,3][1,] 1 3 5[2,] 2 4 6> t(A);[,1] [,2][1,] 1 2[2,] 3 4[3,] 5 62.求方陣的行列式函數det()是求矩陣…

使用Linux命令行歸檔文件

存檔文件 (Archiving Files) As we already understand what Compression (Compression techniques in Linux) is? We shall learn about Archives. We prefer compression as it is convenient to send file compressed through a network but sometimes it is not a smart w…

http緩存機制之304狀態碼

在網上看到一篇關于解釋瀏覽器緩存更新機制304狀態碼的文章,里面說如果請求頭中的If-Modified-Since字段和If-None-Match字段的值分別和響應頭中的Last-Modified字段和Etag字段值一致,服務器就會返回304狀態碼(無響應體),瀏覽器就從本地讀取緩…

東北大學 計算機技術導師,報考東北大學 計算機技術 329分 求調劑相關專業

自薦類型:碩士自薦報考院校:東北大學報考專業:(專業碩士)計算機技術[085211]本科院校:沈陽工程學院本科專業:計算機科學與技術初試成績:總分:329政治:69 英語:71 …

c語言i++和++i程序_使用C ++程序修改鏈接列表的內容

c語言i和i程序Problem statement: 問題陳述: Given a linked list, you modified that linked list in such a way that the elements of the first half of that linked list are the difference of the first node to the last node and next node is the differ…

原生js設置div隱藏或者顯示_10種JS控制DIV的顯示隱藏代碼

div隱藏與顯示#menus {background-color: #c4cff0;}function Layer_HideOrShow(cur_div){ var currentdocument.getElementById(cur_div);if(current.style.visibility"hidden"){current.style.visibility "visible";}else{current.style.visibility "…

計算機工作對身體有害嗎,在電腦前長時間工作會對身體有害處嗎?

病情分析:目前,電腦對人體生理和心理方面的負面影響已日益受到人們的重視.為此科學使用電腦,減少電腦和網絡的危害是十分必要的.指導意見:一是要增強自我保健意識工作間隙注意適當休息,一般來說,電腦操作人員在連續工作1小時后應該休息10分鐘左右.并且最…