日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

List and ArrayList

發布時間:2023/11/27 生活经验 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 List and ArrayList 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
List<> and ArrayList Class Diagrams

Using the Bit Complement of the BinarySearch() Result
代碼
?1using?System;
?2using?System.Collections.Generic;
?3class?Program
?4{
?5????static?void?Main()
?6????{
?7????????List<string>?list?=?new?List<string>();
?8????????int?search;
?9
10????????list.Add("public");
11????????list.Add("protected");
12????????list.Add("private");
13
14????????list.Sort();
15
16????????search?=?list.BinarySearch("protected?internal");
17????????if?(search?<?0)
18????????{
19????????????/**//*The?bitwise?complement?(~)?of?this?value?is?
20?????????????*?the?index?of?the?next?element?larger?than?the?
21?????????????*?element?being?sought,?or?the?total?element?count?
22?????????????*?if?there?is?no?greater?value.?This?provides?a?
23?????????????*?convenient?means?to?insert?new?values?into?the?
24?????????????*?list?at?the?specific?location?so?as?to?maintain?sorting?*/

25????????????list.Insert(~search,?"protected?internal");
26????????}

27
28????????foreach?(string?accessModifier?in?list)
29????????{
30????????????Console.WriteLine(accessModifier);
31????????}

32????????Console.ReadKey();
33????}

34}
?

Demonstrating FindAll() and Its Predicate Parameter
代碼
?1using?System;
?2using?System.Collections.Generic;
?3using?Microsoft.VisualStudio.TestTools.UnitTesting;
?4
?5class?Program
?6{
?7
?8????static?void?Main()
?9????{
10????????List<int>?list?=?new?List<int>();
11????????list.Add(1);
12????????list.Add(2);
13????????list.Add(3);
14????????list.Add(2);
15
16????????List<int>?results?=?list.FindAll(Even);
17????????/**//*
18?????????*?命名空間:Microsoft.VisualStudio.TestTools.UnitTesting
19?????????*?程序集:Microsoft.VisualStudio.QualityTools.UnitTestFramework(在?microsoft.visualstudio.qualitytools.unittestframework.dll?中)
20?????????*/

21????????Assert.AreEqual(2,?results.Count);
22????????Assert.IsTrue(results.Contains(2));
23????????Assert.IsFalse(results.Contains(3));
24????}

25????public?static?bool?Even(int?value)
26????{
27????????if?((value?%?2)?==?0)
28????????{
29????????????return?true;
30????????}

31????????else
32????????{
33????????????return?false;
34????????}

35????}

36}

轉載于:https://www.cnblogs.com/nanshouyong326/archive/2007/05/10/741889.html

總結

以上是生活随笔為你收集整理的List and ArrayList的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。