找到 34423 篇文章 编程
474 次浏览
要获取 Dictionary 中键值对的数量,代码如下:示例 实时演示使用 System;使用 System.Collections.Generic;公共类演示{ 公共静态无效 Main(){ 字典 dict = 新字典(); dict.Add("One", "Chris"); dict.Add("Two", "Steve"); dict.Add("Three", "Messi"); dict.Add("Four", "Ryan"); dict.Add("Five", "Nathan"); Console.WriteLine("元素数量 = " + dict.Count); Console.WriteLine("键值对..."); 针对(键值对 res 在 dict 中){ Console.WriteLine("键 = {0},值 = {1}",res.Key,res.Value); ... 阅读更多
397 次浏览
要将指定的 64 位有符号整数重新解释为双精度浮点数,代码如下:示例 实时演示使用 System;公共类演示{ 公共静态无效 Main() { 长 d = 9846587687; Console.Write("值(64 位有符号整数)= " + d); 双精度 res = BitConverter.Int64BitsToDouble(d); Console.Write("值(双精度浮点数)= " + res); } }输出这将产生以下输出:值 (64 位 有符号 整数) = 9846587687 值 (双精度 浮点数) = 4.86486070491012E-314示例让我们看另一个示例: 实时演示使用 System;公共类演示{ 公共静态无效 Main() { 长 d = 20; ... 阅读更多
292 次浏览
要将指定字符串的值转换为等效的 Unicode 字符,代码如下:示例 实时演示使用 System;公共类演示{ 公共静态无效 Main(){ 布尔 res; 字符 ch; res = Char.TryParse("10",out ch); Console.WriteLine(res); Console.WriteLine(ch.ToString()); } }输出这将产生以下输出:False示例现在让我们看另一个示例: 实时演示使用 System;公共类演示{ 公共静态无效 Main(){ 布尔 res; 字符 ch; res = Char.TryParse("P",out ch); Console.WriteLine(res); Console.WriteLine(ch.ToString()); } }输出这将产生以下输出:True P
319 次浏览
要将指定的双精度浮点数转换为 64 位有符号整数,代码如下:示例 实时演示使用 System;公共类演示{ 公共静态无效 Main() { 双精度 d = 5.646587687; Console.Write("值 = " + d); 长 res = BitConverter.DoubleToInt64Bits(d); Console.Write("64 位有符号整数 = " + res); } }输出这将产生以下输出:值 = 5.646587687 64 位 有符号 整数 = 4618043510978159912示例让我们看另一个示例: 实时演示使用 System;公共类演示{ 公共静态无效 Main() { 双精度 d = 0.001; Console.Write("值 = " + d); ... 阅读更多
219 次浏览
要将当前 DateTime 对象的值转换为 Windows 文件时间,代码如下:示例 实时演示使用 System;公共类演示{ 公共静态无效 Main() { DateTime d = DateTime.Now; Console.WriteLine("日期 = {0}",d); 长 res = d.ToFileTime(); Console.WriteLine("Windows 文件时间 = {0}",res); } }输出这将产生以下输出:日期 = 2019/10/16 上午 8:17:26 Windows 文件 时间 = 132156874462559390示例让我们看另一个示例: 实时演示使用 System;公共类演示{ 公共静态无效 Main() { DateTime d = 新 DateTime(2019, 05, 10, 6, ... 阅读更多
70 次浏览
要获取一个迭代遍历 StringDictionary 的枚举器,代码如下:示例 实时演示使用 System.Collections;使用 System.Collections.Specialized;公共类演示{ 公共静态无效 Main() { StringDictionary strDict1 = 新 StringDictionary(); strDict1.Add("A","John"); strDict1.Add("B","Andy"); strDict1.Add("C","Tim"); strDict1.Add("D","Ryan"); strDict1.Add("E","Kevin"); strDict1.Add("F","Katie"); strDict1.Add("G","Brad"); Console.WriteLine("StringDictionary1 元素..."); 针对(字典条目 de 在 strDict1 中){ Console.WriteLine(de.Key + " " + de.Value); } ... 阅读更多
409 次浏览
foreach 循环会针对实现 System.Collections.IEnumerable 或 System.Collections.Generic.IEnumerable 接口的类型的每个实例中的每个元素执行语句或语句块。示例让我们来看一个 foreach 循环的示例 - 实时演示使用 System; 使用 System.Collections.Generic; 公共类 Demo { 公共静态 void Main(){ LinkedList linkedList = new LinkedList(); linkedList.AddLast(25); linkedList.AddLast(50); linkedList.AddLast(100); linkedList.AddLast(200); linkedList.AddLast(400); linkedList.AddLast(500); linkedList.AddLast(550); linkedList.AddLast(600); linkedList.AddLast(800); linkedList.AddLast(1200); Console.WriteLine("Count ... 阅读更多
61 次查看
要获取遍历 SortedSet 的枚举器,代码如下 - 示例实时演示使用 System; 使用 System.Collections.Generic; 公共类 Demo { 公共静态 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"); ... 阅读更多
数据结构
网络
关系数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP