找到关于编程的34423 篇文章

检查 C# 中 Hashtable 是否已同步

AmitDiwan
更新于 2019年12月6日 10:04:21

85 次浏览

要检查 Hashtable 是否已同步,代码如下所示 −示例 在线演示using System; using System.Collections; public class Demo { public static void Main() { Hashtable hash = new Hashtable(); hash.Add("One", "Katie"); hash.Add("Two", "John"); hash.Add("Three", "Barry"); hash.Add("Four", ""); hash.Add("Five", "Harry"); hash.Add("Six", "F"); hash.Add("Seven", "Tom"); hash.Add("Eight", "Andy"); hash.Add("Nine", "I"); hash.Add("Ten", "Tim"); Console.WriteLine("Hashtable 的键值对..."); foreach(DictionaryEntry entry in hash) { ... 阅读更多

从 C# 中的列表中删除指定的元素

AmitDiwan
更新于 2019年12月6日 10:00:23

74 次浏览

要从列表中删除指定的元素,代码如下所示 −示例 在线演示using System; using System.Collections.Generic; public class Demo { public static void Main(String[] args) { List list1 = new List(); list1.Add("One"); list1.Add("Two"); list1.Add("Three"); list1.Add("Four"); list1.Add("Five"); Console.WriteLine("List1 中的元素..."); foreach (string res in list1) { Console.WriteLine(res); } List list2 = new List(); list2.Add("India"); list2.Add("US"); ... 阅读更多

从 C# 中的 ArrayList 中删除特定对象的第一次出现

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

292 次浏览

要从 ArrayList 中删除特定对象的第一次出现,代码如下所示 −示例using 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); } ... 阅读更多

检查 C# 中的 SortedList 是否为只读

AmitDiwan
更新于 2019年12月6日 09:48:45

65 次浏览

要检查 SortedList 是否为只读,代码如下所示 −示例 在线演示using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); list.Add("One", "IT"); list.Add("Two ", "Operations"); list.Add("Three", "Marketing"); list.Add("Four", "Purchase"); list.Add("Five", "Sales"); list.Add("Six", "Finance"); Console.WriteLine("SortedList 元素..."); foreach(DictionaryEntry d in list) { Console.WriteLine(d.Key + " " + d.Value); } Console.WriteLine("值列表...SortedList"); ... 阅读更多

获取 C# 中 SortedList 对象中的键

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

56 次浏览

要获取 SortedList 对象中的键,代码如下所示 −示例 在线演示using System; using System.Collections; public class Demo { public static void Main(String[] args) { SortedList list = new SortedList(); list.Add("One", "Finance"); list.Add("Two", "Marketing"); list.Add("Three", "Sales"); list.Add("Four", "Purchase"); list.Add("Five", "Operations"); list.Add("Six", "IT"); Console.WriteLine("SortedList 元素..."); foreach(DictionaryEntry d in list) { Console.WriteLine(d.Key + " " + d.Value); } Console.WriteLine("键的索引 ... 阅读更多

在 C# 中向 StringDictionary 添加键值对

AmitDiwan
更新于 2019年12月6日 09:37:46

187 次浏览

要向 StringDictionary 添加键值对,代码如下所示 −示例 在线演示using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { StringDictionary strDict = new StringDictionary(); strDict.Add("A", "John"); strDict.Add("B", "Andy"); strDict.Add("C", "Tim"); strDict.Add("D", "Ryan"); strDict.Add("E", "Kevin"); strDict.Add("F", "Katie"); strDict.Add("G", "Brad"); Console.WriteLine("StringDictionary 元素..."); foreach(DictionaryEntry de in strDict) { Console.WriteLine(de.Key + " " + de.Value); } ... 阅读更多

C# 中 BitArray 元素之间的按位异或运算

AmitDiwan
更新于 2019年12月6日 08:10:40

60 次浏览

让我们看看如何实现 BitArray 元素之间的按位异或运算 −示例 在线演示using System; using System.Collections; public class Demo { public static void Main(){ BitArray arr1 = new BitArray(5); BitArray arr2 = new BitArray(5); arr1[0] = false; arr1[1] = false; arr2[0] = false; arr2[1] = true; Console.WriteLine("BitArray1 元素..."); foreach (bool res in arr1){ Console.WriteLine(res); } Console.WriteLine("BitArray2 元素..."); foreach (bool ... 阅读更多

在 C# 中的 ArrayList 末尾添加对象

AmitDiwan
更新于 2019年12月6日 08:07:13

94 次浏览

要将对象添加到 ArrayList 的末尾,代码如下所示 −示例 在线演示using System; using System.Collections; public class Demo { public static void Main(String[] args){ ArrayList list = new ArrayList(); list.Add("Tim"); list.Add("Katie"); list.Add("Amy"); list.Add("Carlos"); list.Add("Chris"); list.Add("Jason"); Console.WriteLine("ArrayList 中的元素..."); foreach (string res in list){ Console.WriteLine(res); } } }输出这将产生以下输出 −ArrayList 中的元素... Tim Katie Amy Carlos ... 阅读更多

如何在 C# 中创建 SortedSet?

AmitDiwan
更新于 2019年12月6日 08:02:33

76 次浏览

要创建 SortedSet,代码如下所示 −示例 在线演示using System; using System.Collections.Generic; public class Demo { public static void Main(){ SortedSet set1 = new SortedSet(); set1.Add("AB"); set1.Add("BC"); set1.Add("CD"); set1.Add("EF"); Console.WriteLine("SortedSet1 中的元素..."); foreach (string res in set1){ Console.WriteLine(res); } SortedSet set2 = new SortedSet(); set2.Add("BC"); set2.Add("CD"); set2.Add("DE"); set2.Add("EF"); set2.Add("AB"); ... 阅读更多

如何在 C# 中检查线程的当前状态?

AmitDiwan
更新于 2019年12月6日 07:58:44

219 次浏览

要检查线程的当前状态,代码如下所示:示例 在线演示使用 System; using System.Threading; public class Demo {    public static void Main(){       Thread thread = new Thread(new ThreadStart(demo1));       ThreadPool.QueueUserWorkItem(new WaitCallback(demo2));       Console.WriteLine("线程的当前状态 = "+thread.ThreadState);       Console.WriteLine("托管线程ID = "+thread.ManagedThreadId);    }    public static void demo1(){       Thread.Sleep(2000);    }    public static void demo2(object stateInfo){       Console.WriteLine("线程属于托管线程池? = "+Thread.CurrentThread.IsThreadPoolThread);    } }输出这将产生以下输出:线程的当前状态 = 未启动 ... 阅读更多

广告
© . All rights reserved.