找到 34423 篇文章,关于编程

比较此实例是否等于 C# 中指定的 object 或 Int64

AmitDiwan
更新于 2019-12-05 11:45:31

59 次查看

要比较此实例是否等于指定的 object 或 Int64,代码如下:示例 在线演示using System; public class Demo {    public static void Main() {       long val1 = 150;       long val2 = 240;       Console.WriteLine("Value1 = "+val1);       Console.WriteLine("Value2 = "+val2);       Console.WriteLine("它们相等吗? = "+val1.Equals(val2));    } }输出这将产生以下输出:Value1 = 150 Value2 = 240 它们 相等吗? = False示例让我们看另一个示例: 在线演示using System; public class Demo {    public static void Main() {       long val1 = ... 阅读更多

检查 Unicode 字符在 C# 中是否为小写字母

AmitDiwan
更新于 2019-12-05 11:30:32

148 次查看

要检查 Unicode 字符是否为小写字母,代码如下:示例 在线演示using System; public class Demo {    public static void Main() {       bool res;       char val = 'K';       Console.WriteLine("Value = "+val);       res = Char.IsLower(val);       Console.WriteLine("该值是小写字母吗? = "+res);    } }输出这将产生以下输出:Value = K 该值是小写字母吗? = False示例让我们看另一个示例: 在线演示using System; public class Demo {    public static void Main() {   ... 阅读更多

检查指定的 Unicode 字符在 C# 中是字母还是十进制数字

AmitDiwan
更新于 2019-12-05 11:25:35

120 次查看

要检查指定的 Unicode 字符是字母还是十进制数字,代码如下:示例 在线演示using System; public class Demo {    public static void Main() {       bool res;       char val = '1';       Console.WriteLine("Value = "+val);       res = Char.IsLetterOrDigit(val);       Console.WriteLine("该值是字母还是数字? = "+res);    } }输出这将产生以下输出:Value = 1 该值 是 字母 还是 数字? = True示例让我们看另一个示例: 在线演示using System; public class Demo {    public static void Main() {       bool res; ... 阅读更多

获取 C# 中值类型 Char 的 TypeCode

AmitDiwan
更新于 2019-12-05 11:22:52

105 次查看

要获取值类型 Char 的 TypeCode,代码如下:示例 在线演示using System; public class Demo {    public static void Main() {       char val = '5';       bool res;       Console.WriteLine("val 的哈希码 = "+val.GetHashCode());       res = val.Equals('m');       Console.WriteLine("返回值 = "+res);       Console.WriteLine("数值 = "+Char.GetNumericValue(val));       TypeCode type = val.GetTypeCode();       Console.WriteLine("类型 = "+type);    } }输出这将产生以下输出:val 的 哈希码 = 3473461 返回值 = False 数值 = 5 类型 = Char示例让我们看另一个示例: 在线演示using System; public class ... 阅读更多

从 C# 中 SortedList 的指定索引中删除

AmitDiwan
更新于 2019-12-05 11:20:22

115 次查看

要从 SortedList 的指定索引中删除,代码如下:示例 在线演示using 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# 中的 StringDictionary 中删除具有指定键的条目

AmitDiwan
更新于 2019-12-05 11:14:01

70 次查看

要从 StringDictionary 中删除具有指定键的条目,代码如下:示例 在线演示using System; using System.Collections; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringDictionary strDict1 = new 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 键值对...");       foreach(DictionaryEntry de in strDict1) {          Console.WriteLine(de.Key + " " + de.Value);     ... 阅读更多

从 C# 中的 OrderedDictionary 中删除具有指定键的条目

AmitDiwan
更新于 2019-12-05 11:10:13

117 次查看

要从 C# 中的 OrdererdDictionary 中删除具有指定键的条目,代码如下:示例 在线演示using 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);       }   ... 阅读更多

获取 C# 中队列开头的对象 – Peek 操作

AmitDiwan
更新于 2019-12-05 11:04:35

102 次查看

要获取队列开头的对象,代码如下:示例 在线演示using System; using System.Collections.Generic; public class Demo {    public static void Main() {       Queue queue = new Queue();       queue.Enqueue("A");       queue.Enqueue("B");       queue.Enqueue("C");       queue.Enqueue("D");       queue.Enqueue("E");       queue.Enqueue("F");       queue.Enqueue("G");       Console.WriteLine("元素数量 = "+queue.Count);       Console.WriteLine("队列开头的元素 = " + queue.Peek());    } }输出这将产生以下输出:元素数量 = 7 队列开头的元素 = A示例让我们看另一个 ... 阅读更多

获取或设置 C# 中 SortedList 中与指定键关联的值

AmitDiwan
更新于 2019-12-05 10:57:14

86 次查看

要获取或设置与 SortedList 中指定键关联的值,代码如下:示例 在线演示using System; using System.Collections; public class Demo {    public static void Main() {       SortedList list = new SortedList ();       list.Add("A", "Books");       list.Add("B", "Electronics");       list.Add("C", "Appliances");       list.Add("D", "Pet Supplies");       list.Add("E", "Clothing");       list.Add("F", "Footwear");       Console.WriteLine("与键 E 关联的值 = "+list["E"]);       list["E"] = "HDD";       Console.WriteLine("与键 E 关联的值 [已更新] = "+list["E"]);   ... 阅读更多

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

AmitDiwan
更新于 2019-12-05 10:53:23

107 次查看

要检查两个StringDictionary对象是否相等,代码如下所示:示例 在线演示使用 System; using System.Collections.Specialized; public class Demo {    public static void Main() {       StringDictionary strDict1 = new 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");       StringDictionary strDict2 = new StringDictionary();       strDict2.Add("A", "John");       strDict2.Add("B", "Andy");       strDict2.Add("C", "Tim");       strDict2.Add("D", ... 阅读更多

广告
© . All rights reserved.