找到 34423 篇文章 针对 编程
122 次浏览
要获取当前 Decimal 实例的哈希码,代码如下:示例 实时演示使用 System; 公共类 Demo { 公共静态 void Main(){ 十进制 val = 135269.38193M; Console.WriteLine("十进制值 = {0}", val); Console.WriteLine("哈希码 = {0}", (val.GetHashCode()) ); } }输出这将产生以下输出:十进制值 = 135269.38193 哈希码 = 1328665595示例让我们再看一个例子: 实时演示使用 System; 公共类 Demo { 公共静态 void Main(){ 十进制 val = Decimal.MaxValue; Console.WriteLine("十进制值 = {0}", val); Console.WriteLine("哈希码 = {0}", (val.GetHashCode()) ); } }输出这将产生以下输出:十进制值 = 79228162514264337593543950335 哈希码 = 1173356544
87 次浏览
要将指定的逻辑值的字符串表示形式转换为其布尔等价物,代码如下:示例 实时演示使用 System; 公共类 Demo { 公共静态 void Main(){ 布尔 val; 布尔 flag; val = Boolean.TryParse("true", out flag); Console.WriteLine("结果 = "+val); } }输出这将产生以下输出:示例 实时演示使用 System; 公共类 Demo { 公共静态 void Main() { 布尔 val; 布尔 flag; val = Boolean.TryParse("$", out flag); Console.WriteLine("结果 = "+val); } }输出这将产生以下输出:结果 = False
2K+ 次浏览
要将当前 DateTime 对象的值转换为协调世界时 (UTC),代码如下:示例 实时演示使用 System; 公共类 Demo { 公共静态 void Main() { DateTime d = new DateTime(2019, 12, 11, 7, 11, 25); Console.WriteLine("日期 = {0}", d); DateTime res = d.ToUniversalTime(); Console.WriteLine("字符串表示形式 = {0}", res); } }输出这将产生以下输出:日期 = 2019年11月11日上午7:11:25 字符串表示形式 = 2019年11月11日上午7:11:25示例让我们再看一个例子: 实时演示使用 System; 公共类 Demo { 公 ... 阅读更多
284 次浏览
要获取列表的容量,代码如下:示例 实时演示使用 System.Collections.Generic; 公共类 Demo { 公共静态 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 中的元素..."); 针对 (字符串 res 在 list1){ Console.WriteLine(res); } Console.WriteLine("List1 的容量 = "+list1.Capacity); List list2 = new List(); list2.Add("India"); ... 阅读更多
198 次浏览
让我们看一个获取两个 HashSet 并集的示例示例 实时演示使用 System.Collections.Generic; 公共类 Demo { 公共静态 void Main(){ HashSet set1 = new HashSet(); set1.Add(100); set1.Add(200); set1.Add(300); set1.Add(400); set1.Add(500); set1.Add(600); Console.WriteLine("HashSet1 元素..."); 针对(整数 ele 在 set1){ Console.WriteLine(ele); } HashSet set2 = new HashSet(); set2.Add(100); set2.Add(200); set2.Add(300); ... 阅读更多
104 次浏览
要检查 HashSet 和指定的集合是否包含相同的元素,代码如下:示例 实时演示使用 System.Collections.Generic; 公共类 Demo { 公共静态 void Main() { HashSet set1 = new HashSet(); set1.Add("One"); set1.Add("Two"); set1.Add("Three"); set1.Add("Four"); set1.Add("Five"); set1.Add("Six"); set1.Add("Seven"); HashSet set2 = new HashSet(); set2.Add("One"); set2.Add("Two"); set2.Add("Three"); set2.Add("Four"); Console.WriteLine("它是否包含相同 ... 阅读更多
111 次浏览
要获取包含 OrderedDictionary 中键的 ICollection,代码如下:示例 实时演示使用 System.Collections; 使用 System.Collections.Specialized; 公共类 Demo { 公共静态 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.Keys; String[] strKeys = new String[dict.Count]; col.CopyTo(strKeys, 0); ... 阅读更多
2K+ 次浏览
是的,任何 lambda 表达式在 Java 中都是一个对象。它是函数式接口的一个实例。我们已将 lambda 表达式分配给任何变量,并像任何其他对象一样传递它。语法(参数) -> 表达式 或 (参数) -> { 语句; }在下面的示例中,如何将 lambda 表达式分配给变量以及如何调用它。示例@FunctionalInterface 接口 ComparatorTask { 公共布尔 compare(整数 t1, 整数 t2); } 公共类 LambdaObjectTest { 公共静态 void main(String[] args) { ComparatorTask ctask = (整数 t1, 整数 t2) -> {返回 t1 ... 阅读更多
152 次浏览
要返回当前枚举类型的基础类型,代码如下:示例 实时演示使用 System; 公共类 Demo { 枚举 Vehicle {Car, Bus, Bike, Airplane} 公共静态 void Main() { 尝试 { Vehicle v = Vehicle.Bike; Type type = v.GetType(); 字符串[] str = type.GetEnumNames(); Console.WriteLine("GetEnumName() 返回常量名称 = " + str); Type type2 = type.GetEnumUnderlyingType(); Console.Write("枚举基础类型 = "+type2); Console.WriteLine("列出 ... 阅读更多
43 次浏览
要获取当前枚举类型的成员名称,代码如下:示例 实时演示使用 System;public class Demo { enum Vehicle {Car, Bus, Bike} public static void Main() { try { Type type = typeof(string); string[] str = type.GetEnumNames(); Console.WriteLine("GetEnumName() 返回常量名称 = " + str); Console.WriteLine("列出常量.."); for (int i = 0; i < str.Length; i++) Console.Write("{0} ", str[i]); ... 阅读更多
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP