北大青鳥(niǎo)c 教程tpnew(Beida Jade Bird ctutorial tpnew)_第1頁(yè)
北大青鳥(niǎo)c 教程tpnew(Beida Jade Bird ctutorial tpnew)_第2頁(yè)
北大青鳥(niǎo)c 教程tpnew(Beida Jade Bird ctutorial tpnew)_第3頁(yè)
北大青鳥(niǎo)c 教程tpnew(Beida Jade Bird ctutorial tpnew)_第4頁(yè)
北大青鳥(niǎo)c 教程tpnew(Beida Jade Bird ctutorial tpnew)_第5頁(yè)
已閱讀5頁(yè),還剩6頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、北大青鳥(niǎo)c#教程tpnew11(Beida Jade Bird c# tutorial tpnew11)This article is contributed by ljw460Ppt documents may experience poor browsing on the WAP side. It is recommended that you first select TXT, or download the source file to the local view.Chapter eleventh arrays and collections objectsACCP V4.0revi

2、ewA thread is in the shared memory space in multi concurrent execution path in C#, using the System.Threading namespace Thread class to create a thread thread priority can be changed to lock value of the C# keyword in the definition of the ThreadPriority enumeration is a method of thread thread sync

3、hronization synchronization is called thread safe unless absolutely necessary, otherwise do not create thread safe code, because adding unnecessary locking reduces performanceTwoACCP V4.0targetUse the System.Array object to understand the features and advantages of a collection object, using the Sys

4、tem.ArrayList object using a hash table objectThreeACCP V4.0System.Array profile 3-1Store student scores564Array applicationSevenOneFourInt Score1; int score= new int7 score 0; the first student scores of System.Console.ReadLine (Score1) int score2; score 1 second students score System.Console.ReadL

5、ine (score2) int score3 score 2 3; third students score System.Console.ReadLine (score3) int score4; score 3 fourth students score System.Console.ReadLine (score4) int score5 score 4 2; fifth students score System.Console.ReadLine (score5) int score6; score 5 sixth students score System.Console.Read

6、Line (score6) in the array in terms of elements stored in the array, the array length index in the group of int score7; the total value of the storage, the total dimension of the array to array rank score 6 ACCP seventh V4.0 System.Console.ReadLine scores (score7)System.Array profile 3-2Array defini

7、tion: data type array name;Int MyArray = 1,2,3,4,5,6,7;How do you easily perform array manipulation?MyArray0, MyArray1, MyArray2. MyArray6 can perform various operations such as storage, retrieval, sorting, and inversionMyArray 0 = 604FiveACCP V4.0System.Array profile 3-3System.ArrayArray is an abst

8、ract base class that provides the CreateInstance method to create arraysArray obj = Array.CreateInstance (typeof (string), 10);SixACCP V4.0The properties and methods of System.ArrayattributeLength Rank IsReadOnly IsFixedSizeMethodBinarySearch Copy CreateInstanceGetLowerBound GetUpperBound LastIndexO

9、f SetValueClear CopyToGetLength, GetValue, IndexOf, Reverse, SortSevenACCP V4.0Example 2-1Static void Main (string args) / / objNames = Array.CreateInstance to construct objNames array Array (typeof (string), 5); / / initialize instantiate objNames as string objects and the storage of 5 elements of

10、objNames.SetValue (A, 0); objNames.SetValue (B, 1); objNames.SetValue (C. 2); objNames.SetValue (D, 3); objNames.SetValue (E, 4); Console.WriteLine (array); SetValue (for (int) method to store string CTR = 0; CTR 5; ctr+) Console.writeline (元素 0: 1 + 1, ctr, objnames.getvalue (ctr) (方法檢索數(shù)組值 使用 getva

11、lue);8accp v4.0示例 2 - 2console.writeline (n數(shù)組中元素的總數(shù)是 0, objnames.length.tostring (); / / 輸出數(shù)組秩 console.writeline (n數(shù)組秩是 0, objnames.rank.tostring (); / / 反轉(zhuǎn)數(shù)組并輸出 顯示 objnames數(shù)組秩 array.reverse (objnames); console.writeline (n反轉(zhuǎn)數(shù)組后); 反轉(zhuǎn)數(shù)組元素 for (int ctr = 0; ctr 5; ctr console.writeline (+ +) 0: 1 元素 ,

12、 ctr + 1, objnames.getvalue (ctr) 反轉(zhuǎn)后的數(shù)組元素列表 顯示 objnames數(shù)組的長(zhǎng)度);課堂練習(xí):這段代碼用for each結(jié)構(gòu)怎么寫(xiě)?9accp v4.0思考和演示使用 int = 和使用: one! two! three! b.createinstance (typeof (string), 5) 創(chuàng)建的數(shù)組, a可以使用b所有的屬性和方法嗎?教員演示兩種數(shù)組的差別10accp v4.0system collections 簡(jiǎn)介 2 - 1.對(duì)象的集合 employeeid工作檔案id工作檔案id工作檔案id工作檔案職員 1職員 2職員 3職員 4對(duì)象

13、組中元素個(gè)數(shù)未知, 并且隨時(shí)可能要循環(huán), 添加和移除11accp v4.0system collections 簡(jiǎn)介 2 - 2.命名空間 collection system.system collections arraylist hashtable sortedlist classes.類(lèi)interfaces icollection ienumerator接口 ilistdictionaryentry 結(jié)構(gòu) structures12accp v4.0hashtablehashtable 類(lèi)將人名引用為 hash (或鍵) 并將電話號(hào)碼引用為值give me the keys 屬性 coun

14、t values方法 getenumerat or removehashtable objfrienddetails = new hashtable ();13accp v4.0使用哈希表對(duì)象14教員演示使用哈希表的例子程序accp v4.0arraylist 類(lèi) 2 - 1arraylist的特點(diǎn)類(lèi)的容量或元素?cái)?shù)是固定的 array, 而 arraylist 類(lèi)的容 量可以根據(jù)需要?jiǎng)討B(tài)擴(kuò)展.通過(guò)設(shè)置 arraylist.capacity 的值可以重新分配內(nèi)存和復(fù)制元素 使用 arraylist 提供的方法可以同時(shí)添加, 插入或移除一 個(gè)范圍內(nèi)的元素?cái)?shù)組靈活性可以設(shè)置數(shù)組的下界 數(shù)組可以有多個(gè)

15、維 許多需要使用數(shù)組的實(shí)例都可以使用arraylist15accp v4.0arraylist 類(lèi) 2 - 2屬性 capacity count 方法 give contains insert remove removeat trimtosize16accp v4.0簡(jiǎn)單的例子arraylist list = new arraylist (); / / 給數(shù)組增加10個(gè)int元素 for (int i = 0; i 10; i + +) list.add (s); / / / / 將第6個(gè)元素移除.程序做一些處理 list.removeat (5); / / 再增加3個(gè)元素 for (int

16、i = 0; i 3; i + +) (i + list.add 20); / / 返回arraylist包含的數(shù)組 int32 values = (, int32) list.toarray (typeof );17accp v4.0使用arraylist對(duì)象教員演示使用arraylist的例子程序EighteenACCP V4.0summaryMost programming languages provide an array of the data structure, CreateInstance method with multiple data elements are stor

17、ed in the same type can use the Array class to create a Array object, can also be directly defined array collections of objects can be used to manage dynamically created at run-time element in the System.Collections namespace provides a set of interfaces and classes, so that users can a set of data elements to perform various set operations the user can through the HashTable class data, as a

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論