HashSet<T>不重復(fù)的無序列表
十年的永靖網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整永靖建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。成都創(chuàng)新互聯(lián)公司從事“永靖網(wǎng)站設(shè)計(jì)”,“永靖網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
SortedSet<T>不重復(fù)的有序列表
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication8 { class Program { static void Main(string[] args) { //=============================【HashSet<T>】============================== //-----------------添加 HashSet<string> test = new HashSet<string> { "a", "b", "c" }; if (!test.Add("a"))//如果列表中存在就不會(huì)添加,并返回false Console.WriteLine("該元素已存在,不添加"); if (test.Add("d")) Console.WriteLine("添加元素成功"); //-----------------比較 HashSet<string> test1 = new HashSet<string> { "a", "b", "c"}; HashSet<string> test2 = new HashSet<string> { "a", "b", "c","d" }; if (test1.IsSubsetOf(test2)) { Console.WriteLine("test1的每個(gè)元素test2都有"); } if (test1.IsSubsetOf(test2)) { Console.WriteLine("test2相對(duì)于test1有額外的元素"); } if (test1.Overlaps(test2)) { Console.WriteLine("test2與test1有共同的元素"); } //=============================【HashSet<T>】============================== //------------添加集 SortedSet<string> sd = new SortedSet<string>(test1);//將test1中的所有元素添加到有序列表中 sd.UnionWith(test2);//將test2中的所有元素添加到有序列表中【結(jié)果會(huì)排除重復(fù)的元素,并排序】 sd.Add("aa"); //------------刪除集 sd.Remove("d");//刪除匹配的元素 sd.RemoveWhere(r => r == "aa");//刪除匹配的元素 sd.ExceptWith(test1);//刪除集 foreach (var item in sd) { Console.WriteLine(item); } Console.ReadKey(); } } }
本文題目:集---HashSet<T>與SortedSet<T>
當(dāng)前URL:http://vcdvsql.cn/article46/jhgihg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供電子商務(wù)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站內(nèi)鏈、網(wǎng)站導(dǎo)航、App開發(fā)、
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)