找到关于编程的34423 篇文章
122 次浏览
要获取当前 Decimal 实例的哈希码,代码如下:示例 在线演示using System; public class Demo { public static void Main(){ Decimal val = 135269.38193M; Console.WriteLine("Decimal 值 = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); } }输出这将产生以下输出:Decimal 值 = 135269.38193 HashCode = 1328665595示例让我们来看另一个示例: 在线演示using System; public class Demo { public static void Main(){ Decimal val = Decimal.MaxValue; Console.WriteLine("Decimal 值 = {0}", val); Console.WriteLine("HashCode = {0}", (val.GetHashCode()) ); } }输出这将产生以下输出:Decimal 值 = 79228162514264337593543950335 HashCode = 1173356544
87 次浏览
要将逻辑值的指定字符串表示形式转换为其布尔等效项,代码如下:示例 在线演示using System; public class Demo { public static void Main(){ bool val; bool flag; val = Boolean.TryParse("true", out flag); Console.WriteLine("Result = "+val); } }输出这将产生以下输出:示例 在线演示using System; public class Demo { public static void Main() { bool val; bool flag; val = Boolean.TryParse("$", out flag); Console.WriteLine("Result = "+val); } }输出这将产生以下输出:Result = False
2K+ 次浏览
要将当前 DateTime 对象的值转换为协调世界时 (UTC),代码如下:示例 在线演示using System; public class Demo { public static void Main() { DateTime d = new DateTime(2019, 12, 11, 7, 11, 25); Console.WriteLine("Date = {0}", d); DateTime res = d.ToUniversalTime(); Console.WriteLine("String representation = {0}", res); } }输出这将产生以下输出:Date = 2019/11/11 7:11:25 AM String representation = 2019/11/11 7:11:25 AM示例让我们来看另一个示例: 在线演示using System; public class Demo { public ... 阅读更多
284 次浏览
要获取列表的容量,代码如下:示例 在线演示using System; using System.Collections.Generic; public class Demo { public static void Main(String[] args){ List
198 次浏览
让我们来看一个获取两个 HashSet 并集的示例示例 在线演示using System; using System.Collections.Generic; public class Demo { public static void Main(){ HashSet
104 次浏览
要检查 HashSet 和指定集合是否包含相同的元素,代码如下:示例 在线演示using System; using System.Collections.Generic; public class Demo { public static void Main() { HashSet
111 次浏览
要获取包含 OrderedDictionary 中键的 ICollection,代码如下:示例 在线演示using System; using 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.Keys; String[] strKeys = new String[dict.Count]; col.CopyTo(strKeys, 0); ... 阅读更多
2K+ 次浏览
是的,任何 lambda 表达式在 Java 中都是一个对象。它是函数式接口的一个实例。我们将 lambda 表达式分配给任何变量,并像任何其他对象一样传递它。语法(参数) -> 表达式 或 (参数) -> { 语句; }在下面的示例中,lambda 表达式如何分配给变量以及如何调用它。示例@FunctionalInterface interface ComparatorTask { public boolean compare(int t1, int t2); } public class LambdaObjectTest { public static void main(String[] args) { ComparatorTask ctask = (int t1, int t2) -> {return t1 ... 阅读更多
152 次浏览
要返回当前枚举类型的基础类型,代码如下:示例 在线演示使用 System; public class Demo { enum Vehicle {Car, Bus, Bike, Airplane} public static void Main() { try { Vehicle v = Vehicle.Bike; Type type = v.GetType(); string[] 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