找到 34423 篇文章,关于编程

在 C# 中将 StringDictionary 复制到指定索引处的数组

AmitDiwan
更新于 2019 年 12 月 10 日 10:26:27

76 次浏览

要将 StringDictionary 复制到指定索引处的数组,代码如下:示例 在线演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类 Demo {    公共静态 void Main(){       StringDictionary strDict = new StringDictionary();       strDict.Add("1", "SUV");       strDict.Add("2", "AUV");       strDict.Add("3", "电动汽车");       strDict.Add("4", "公用车辆");       strDict.Add("5", "掀背车");       strDict.Add("6", "紧凑型汽车");       strDict.Add("7", "多用途汽车");       strDict.Add("8", "跨界车");       strDict.Add("9", "敞篷车");       strDict.Add("10", "四轮车");       DictionaryEntry[] arr = { new DictionaryEntry(), ... 阅读更多

在 C# 中将 StringCollection 复制到数组的指定索引处

AmitDiwan
更新于 2019 年 12 月 10 日 10:20:29

80 次浏览

要将 StringCollection 复制到数组的指定索引处,代码如下:示例 在线演示使用 System;使用 System.Collections.Specialized;公共类 Demo {    公共静态 void Main(){       StringCollection strCol = new StringCollection();       String[] strArr = new String[] { "Tim", "Tom", "Sam", "Mark", "Katie", "Jacob"};       Console.WriteLine("元素...");       对于 (int i = 0; i < strArr.Length; i++) {          Console.WriteLine(strArr[i]);       }       strCol.AddRange(strArr);       String[] arr = new String[strCol.Count];       strCol.CopyTo(arr, 0);       Console.WriteLine("元素...复制后... 阅读更多

在 C# 中将 OrderedDictionary 元素复制到指定索引处的数组实例

AmitDiwan
更新于 2019 年 12 月 10 日 10:17:30

85 次浏览

要将 OrderedDictionary 元素复制到指定索引处的数组实例,代码如下:示例 在线演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类 Demo {    公共静态 void Main(){       OrderedDictionary dict = new OrderedDictionary ();       dict.Add(1, "Harry");       dict.Add(2, "Mark");       dict.Add(3, "John");       dict.Add(4, "Jacob");       dict.Add(5, "Tim");       Console.WriteLine("OrderedDictionary 元素...");       对于每个 (DictionaryEntry d 在 dict 中){          Console.WriteLine(d.Key + " " + d.Value);       }       DictionaryEntry[] dictArr = new DictionaryEntry[dict.Count]; ... 阅读更多

在 C# 中将 ListDictionary 复制到指定索引处的数组实例

AmitDiwan
更新于 2019 年 12 月 10 日 10:14:06

65 次浏览

要将 ListDictionary 复制到指定索引处的数组实例,代码如下:示例 在线演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类 Demo {    公共静态 void Main(){       ListDictionary dict = new ListDictionary();       dict.Add(1, "Harry");       dict.Add(2, "Mark");       dict.Add(3, "John");       dict.Add(4, "Jacob");       dict.Add(5, "Tim");       dict.Add(6, "Sam");       dict.Add(7, "Tom");       dict.Add(8, "Kevin");       Console.WriteLine("ListDictionary 元素...");       对于每个 (DictionaryEntry d 在 dict 中){          Console.WriteLine(d.Key + " " + ... 阅读更多

在 C# 中向 HybridDictionary 添加指定的键和值

AmitDiwan
更新于 2019 年 12 月 10 日 10:09:25

65 次浏览

要向 HybridDictionary 添加指定的键和值,代码如下:示例 在线演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类 Demo {    公共静态 void Main(){       HybridDictionary dict = new HybridDictionary();       dict.Add("A", "包袋");       dict.Add("B", "电子产品");       dict.Add("C", "智能可穿戴设备");       dict.Add("D", "宠物用品");       Console.WriteLine("HybridDictionary 元素...");       对于每个 (DictionaryEntry d 在 dict 中){          Console.WriteLine(d.Key + " " + d.Value);       }       Console.WriteLine("HybridDictionary 是否具有固定大小?= "+dict.IsFixedSize);       ... 阅读更多

在 C# 中将指定集合的元素添加到 List 的末尾

AmitDiwan
更新于 2019 年 12 月 10 日 10:06:25

62 次浏览

要将指定集合的元素添加到 List 的末尾,代码如下:示例 在线演示使用 System;使用 System.Collections.Generic;公共类 Demo {    公共静态 void Main(String[] args){       List list = new List();       list.Add("Andy");       list.Add("Gary");       list.Add("Katie");       list.Add("Amy");       Console.WriteLine("List 中的元素...");       对于每个 (string res 在 list 中){          Console.WriteLine(res);       }       string[] strArr = { "John", "Jacob" };       list.AddRange(strArr);       Console.WriteLine("List 中的元素...已更新"); ... 阅读更多

在 C# 中在 LinkedList 的开头添加新节点或值

AmitDiwan
更新于 2019 年 12 月 10 日 10:03:58

122 次浏览

要向 LinkedList 的开头添加新节点或值,代码如下:示例 在线演示使用 System;使用 System.Collections.Generic;公共类 Demo {    公共静态 void Main(){       LinkedList list = new LinkedList();       list.AddLast("A");       list.AddLast("B");       list.AddLast("C");       list.AddLast("D");       list.AddLast("E");       list.AddLast("F");       Console.WriteLine("节点数 = " + list.Count);       Console.WriteLine("LinkedList 中的元素...");       对于每个 (string res 在 list 中){          Console.WriteLine(res);       }       list.AddLast("G");   ... 阅读更多

检查 OrderedDictionary 集合在 C# 中是否为只读

AmitDiwan
更新于 2019 年 12 月 10 日 09:59:05

69 次浏览

要检查 OrderedDictionary 集合是否为只读,代码如下:示例 在线演示使用 System;使用 System.Collections;使用 System.Collections.Specialized;公共类 Demo {    公共静态 void Main(){       OrderedDictionary dict = new OrderedDictionary();       dict.Add("1", "一");       dict.Add("2", "二");       dict.Add("3", "三");       dict.Add("4", "四");       dict.Add("5", "五");       dict.Add("6", "六");       dict.Add("7", "七");       dict.Add("8", "八");       ICollection col = dict.Values;       String[] strVal = new String[dict.Count];       col.CopyTo(strVal, 0);       Console.WriteLine("显示... 阅读更多

在 C# 中将指定 Decimal 的值转换为等效的 16 位无符号整数

AmitDiwan
更新于 2019 年 12 月 10 日 09:57:03

159 次浏览

将指定 Decimal 值转换为等效的 16 位无符号整数,代码如下 -示例 在线演示使用 System; public class Demo {    public static void Main() {       Decimal val = 875.647m;       Console.WriteLine("Decimal value = "+val);       ushort res = Decimal.ToUInt16(val);       Console.WriteLine("16-bit unsigned integer = "+res);    } }输出这将产生以下输出 -Decimal value = 875.647 16-bit unsigned integer = 875示例让我们看另一个示例 - 在线演示使用 System; public class Demo {    public static void Main() {       Decimal val = 0.001m;       Console.WriteLine("Decimal value ... 阅读更多

检查 OrderedDictionary 集合是否包含 C# 中的特定键

AmitDiwan
更新于 2019年12月10日 09:55:55

134 次查看

要检查 OrderedDictionary 集合是否包含特定键,代码如下 -示例 在线演示使用 System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main(){       OrderedDictionary dict = new OrderedDictionary();       dict.Add("1", "One");       dict.Add("2", "Two");       dict.Add("3", "Three");       dict.Add("4", "Four");       dict.Add("5", "Five");       dict.Add("6", "Six");       dict.Add("7", "Seven");       dict.Add("8", "Eight");       ICollection col = dict.Values;       String[] strVal = new String[dict.Count];       col.CopyTo(strVal, 0);     ... 阅读更多

广告
© . All rights reserved.