找到 34423 篇文章 关于编程
886 次浏览
lambda 表达式包含两个部分,一个是参数,另一个是表达式,这两个部分由箭头 (->) 符号分隔。lambda 表达式可以访问其封闭作用域的变量。lambda 表达式可以访问其封闭类的实例变量和静态变量,并且可以访问最终的或有效最终的局部变量。语法 (参数列表) -> 表达式 示例 interface TestInterface { void print(); } public class LambdaExpressionTest { int a; // 实例变量 static int b; // 静态变量 LambdaExpressionTest(int x) { // 构造函数初始化实例变量 this.a = ... 阅读更多
161 次浏览
让我们首先创建一个表 - mysql> create table DemoTable -> ( -> Value int -> ); 查询成功,0 行受影响 (0.63 秒) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(78); 查询成功,1 行受影响 (0.18 秒) mysql> insert into DemoTable values(89); 查询成功,1 行受影响 (0.11 秒) mysql> insert into DemoTable values(98); 查询成功,1 行受影响 (0.10 秒) mysql> insert into DemoTable values(58); 查询成功,1 行受影响 (0.25 秒) 使用 select 语句显示表中的所有记录 - mysql> select * from DemoTable; 这将产生以下输出 ... 阅读更多
188 次浏览
让我们首先创建一个表 - mysql> create table DemoTable -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentMarks int -> ); 查询成功,0 行受影响 (0.58 秒) 使用 insert 命令在表中插入一些记录。我们还插入了重复记录 - mysql> insert into DemoTable(StudentMarks) values(98); 查询成功,1 行受影响 (0.11 秒) mysql> insert into DemoTable(StudentMarks) values(98); 查询成功,1 行受影响 (0.10 秒) mysql> insert into DemoTable(StudentMarks) values(78); 查询成功,1 行受影响 (0.10 秒) mysql> insert into DemoTable(StudentMarks) values(78); 查询成功,1 行受影响 (0.29 秒) mysql> insert ... 阅读更多
864 次浏览
要将数据从一个表插入到另一个表,请使用 INSERT INTO SELECT 语句。让我们首先创建一个表 - mysql> create table DemoTable1 -> ( -> Id int, -> FirstName varchar(20) -> ); 查询成功,0 行受影响 (0.49 秒) 使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1 values(101, 'Adam'); 查询成功,1 行受影响 (0.12 秒) mysql> insert into DemoTable1 values(102, 'John'); 查询成功,1 行受影响 (0.11 秒) 使用 select 语句显示表中的所有记录 - mysql> select * from DemoTable1; 这将产生以下输出 -+------+-----------+ | Id ... 阅读更多
91 次浏览
要获取当前 UInt32 实例的 HashCode,代码如下所示 - 示例 使用 System; public class Demo { public static void Main() { uint val1 = 100; uint val2 = UInt16.MinValue; Console.WriteLine("val1 的 HashCode = " + val1.GetHashCode()); Console.WriteLine("val2 的 HashCode = " + val2.GetHashCode()); } } 输出 这将产生以下输出 - val1 的 HashCode = 100 val2 的 HashCode = 0 示例 让我们来看另一个示例 - 使用 System; public class Demo { public static void Main() { uint val1 = 50; ... 阅读更多
180 次浏览
让我们来看一个在数组中使用 foreach 循环的示例 - 示例 使用 System; public class Demo { public static void Main() { string[] products = new string[] { "Electronics", "Accessories", "Clothing", "Toys", "Clothing", "Furniture" }; Console.WriteLine("产品列表..."); foreach (string s in products) { Console.WriteLine(s); } Console.WriteLine("数组中是否包含产品 Accessories?= {0}", Array.Exists(products, ele => ele == "Accessories")); Console.WriteLine("数组中是否包含产品 Stationery?= {0}", Array.Exists(products, ele => ele == "Stationery")); ... 阅读更多
115 次浏览
要获取正弦值为浮点值参数的角度,代码如下所示 - 示例 using System; public class Demo { public static void Main() { float val1 = 0.1f; float val2 = 8.9f; Console.WriteLine("角度 (val1) = " + (MathF.Asin(val1))); Console.WriteLine("角度 (val2) = " + (MathF.Asin(val2))); } } 输出 这将产生以下输出 - 角度 (val1) = 0.1001674 角度 (val2) = NaN 示例 让我们来看另一个示例 - using System; public class Demo { public static void Main() { float val1 = 1.2f; float val2 = ... 阅读更多
96 次浏览
要获取浮点值的双曲反余弦,代码如下所示 - 示例 using System; public class Demo { public static void Main() { float val1 = 0.1f; float val2 = 0.9f; Console.WriteLine("角度 (val1) = " + (MathF.Acosh(val1))); Console.WriteLine("角度 (val2) = " + (MathF.Acosh(val2))); } } 输出 这将产生以下输出 - 角度 (val1) = NaN 角度 (val2) = NaN 示例 让我们来看另一个示例 - using System; public class Demo { public static void Main() { float val1 = 5.1f; float val2 = 8.9f; Console.WriteLine("角度 (val1) = " + (MathF.Acosh(val1))); Console.WriteLine("角度 (val2) = " + (MathF.Acosh(val2))); } } 输出 这将产生以下输出 - 角度 (val1) = 2.312634 角度 (val2) = 2.876027
149 次浏览
要检查指定的字符是否具有代理代码,代码如下所示 - 示例 使用 System; public class Demo { public static void Main() { string str = new String(new char[] { 'k', 'm', 'g', 't', '\uD800' }); bool res = Char.IsSurrogate(str, 4); if (res) Console.WriteLine("包含代理值!"); else Console.WriteLine("不包含代理值!"); } } 输出 这将产生以下输出 - 包含代理值! 示例 让我们来看另一个示例 - 使用 System; public class Demo { ... 阅读更多
54 次浏览
要获得对StringDictionary的同步访问,代码如下:示例 在线演示using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ StringDictionary strDict = new StringDictionary (); strDict.Add("A", "Books"); strDict.Add("B", "Electronics"); strDict.Add("C", "Appliances"); strDict.Add("D", "Pet Supplies"); strDict.Add("E", "Clothing"); strDict.Add("F", "Footwear"); Console.WriteLine("StringDictionary键值对..."); foreach(DictionaryEntry de in strDict) { Console.WriteLine(de.Key + " " + de.Value); } Console.WriteLine("值 ... 阅读更多
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP