找到 34423 篇文章 关于编程

如何在 C# 中获取元组的第三个元素?

AmitDiwan
更新于 2019-12-05 07:29:29

96 次浏览

要获取元组的第三个元素,代码如下:示例 实时演示使用 System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       Console.WriteLine("元组1是否等于元组2? = "+tuple1.Equals(tuple2));       Console.WriteLine("元组1的哈希码 = "+tuple1.GetHashCode());       Console.WriteLine("元组2的哈希码 = "+tuple2.GetHashCode());       Console.WriteLine("元组1 第1项 = "+tuple1.Item1);       Console.WriteLine("元组2 第1项 = "+tuple2.Item1);       Console.WriteLine("元组1 第2项 ... 阅读更多

如何在 C# 中获取元组的第六个元素?

AmitDiwan
更新于 2019-12-05 07:25:03

101 次浏览

要获取元组的第六个元素,代码如下:示例 实时演示使用 System; public class Demo {    public static void Main(String[] args){       var tuple1 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(75, 200, 500, 700, 100, 1200, 1500);       Console.WriteLine("元组1是否等于元组2? = "+tuple1.Equals(tuple2));       Console.WriteLine("元组1的哈希码 = "+tuple1.GetHashCode());       Console.WriteLine("元组2的哈希码 = "+tuple2.GetHashCode());       Console.WriteLine("元组1 第1项 = "+tuple1.Item1);       Console.WriteLine("元组2 第1项 = "+tuple2.Item1);       Console.WriteLine("元组1 第2项 ... 阅读更多

在 C# 中从 ArrayList 中删除所有元素

AmitDiwan
更新于 2019-12-05 07:22:05

126 次浏览

要从 ArrayList 中删除所有元素,代码如下:示例 实时演示使用 System; using System.Collections; public class Demo {    public static void Main(String[] args){       ArrayList list1 = new ArrayList();       list1.Add("A");       list1.Add("B");       list1.Add("C");       list1.Add("D");       list1.Add("E");       list1.Add("F");       list1.Add("G");       list1.Add("H");       list1.Add("I");       Console.WriteLine("ArrayList1 中的元素...");       foreach (string res in list1){          Console.WriteLine(res);       }       ArrayList list2 = new ... 阅读更多

在 C# 中从 OrderedDictionary 中删除所有元素

AmitDiwan
更新于 2019-12-05 07:19:04

68 次浏览

要从 OrderedDictionary 中删除所有元素,代码如下:示例 实时演示使用 System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       OrderedDictionary dict = new OrderedDictionary();       dict.Add("A", "Books");       dict.Add("B", "Electronics");       dict.Add("C", "Smart Wearables");       dict.Add("D", "Pet Supplies");       dict.Add("E", "Clothing");       dict.Add("F", "Footwear");       Console.WriteLine("OrderedDictionary 元素...");       foreach(DictionaryEntry d in dict){          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("元素数量 ... 阅读更多

检查 ListDictionary 在 C# 中是否已同步

AmitDiwan
更新于 2019-12-05 07:16:33

72 次浏览

要检查 ListDictionary 是否已同步,代码如下:示例 实时演示使用 System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       ListDictionary dict = new ListDictionary();       dict.Add("1", "SUV");       dict.Add("2", "Sedan");       dict.Add("3", "Utility Vehicle");       dict.Add("4", "Compact Car");       dict.Add("5", "SUV");       dict.Add("6", "Sedan");       dict.Add("7", "Utility Vehicle");       dict.Add("8", "Compact Car");       dict.Add("9", "Crossover");       dict.Add("10", "Electric Car");       Console.WriteLine("ListDictionary 元素...");       foreach(DictionaryEntry d ... 阅读更多

检查 ListDictionary 在 C# 中是否为只读

AmitDiwan
更新于 2019-12-05 07:12:55

82 次浏览

要检查 ListDictionary 是否为只读,代码如下:示例 实时演示使用 System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       ListDictionary dict1 = new ListDictionary();       dict1.Add("A", "Books");       dict1.Add("B", "Electronics");       dict1.Add("C", "Smart Wearables");       dict1.Add("D", "Pet Supplies");       dict1.Add("E", "Clothing");       dict1.Add("F", "Footwear");       Console.WriteLine("ListDictionary1 元素...");       foreach(DictionaryEntry d in dict1){          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("ListDictionary1 是否具有 ... 阅读更多

在 C# 中从 SortedList 中删除所有元素

AmitDiwan
更新于 2019-12-05 07:07:13

86 次浏览

要从 SortedList 中删除所有元素,代码如下:示例 实时演示使用 System; using System.Collections; public class Demo {    public static void Main(String[] args){       SortedList sortedList = new SortedList();       sortedList.Add("A", "1");       sortedList.Add("B", "2");       sortedList.Add("C", "3");       sortedList.Add("D", "4");       sortedList.Add("E", "5");       sortedList.Add("F", "6");       sortedList.Add("G", "7");       sortedList.Add("H", "8");       sortedList.Add("I", "9");       sortedList.Add("J", "10");       Console.WriteLine("SortedList 元素...");       foreach(DictionaryEntry d in sortedList){       ... 阅读更多

在 C# 中从 HashSet 中删除所有元素

AmitDiwan
更新于 2019-12-05 07:04:01

145 次浏览

要从 HashSet 中删除所有元素,代码如下:示例 实时演示使用 System; using System.Collections.Generic; public class Demo {    public static void Main(String[] args){       HashSet set1 = new HashSet();       set1.Add("A");       set1.Add("B");       set1.Add("C");       set1.Add("D");       set1.Add("E");       set1.Add("F");       set1.Add("G");       set1.Add("H");       Console.WriteLine("HashSet1 中的元素...");       foreach (string res in set1){          Console.WriteLine(res);       }       HashSet set2 = new HashSet();     ... 阅读更多

获取 OrderedDictionary 在 C# 中的只读副本

AmitDiwan
更新于 2019-12-05 06:59:05

116 次浏览

要获取 OrderedDictionary 的只读副本,代码如下:示例 实时演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类 Demo {    公共静态无效 Main(){       OrderedDictionary dict1 = 新 OrderedDictionary();       dict1.Add("A", "Books");       dict1.Add("B", "Electronics");       dict1.Add("C", "Smart Wearables");       dict1.Add("D", "Pet Supplies");       dict1.Add("E", "Clothing");       dict1.Add("F", "Footwear");       Console.WriteLine("OrderedDictionary1 元素...");       针对每个(DictionaryEntry d 在 dict1 中){          Console.WriteLine(d.Key + " " + d.Value);       }       OrderedDictionary dict2 ... 阅读更多

检查两个 Tuple 对象在 C# 中是否相等

AmitDiwan
更新于 2019-12-05 06:55:15

111 次查看

要检查两个 Tuple 对象是否相等,代码如下:示例 实时演示使用 System;公共类 Demo {    公共静态无效 Main(字符串[] args){       var tuple1 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500);       var tuple2 = Tuple.Create(150, 400, 500, 700, 100, 1200, 1500);       Console.WriteLine("Tuple1 是否等于 Tuple2?= "+tuple1.Equals(tuple2));    } }输出这将产生以下输出:Tuple1 是否等于 Tuple2?= True示例让我们看看另一个示例: 实时演示使用 System;公共类 Demo {    公共静态无效 Main(字符串[] args){       var tuple1 = ... 阅读更多

广告

© . All rights reserved.