找到 34423 篇文章 关于编程

C# 中的 TimeSpan.FromHours() 方法

AmitDiwan
更新于 2019年12月3日 06:51:14

922 次浏览

C# 中的 TimeSpan.FromHours() 方法用于返回表示指定小时数的 TimeSpan,该规范精确到毫秒。语法语法如下:public static TimeSpan FromHours (double val);上述 val 值是精确到毫秒的小时数。示例让我们来看一个示例:实时演示using System; public class Demo { public static void Main(){ TimeSpan span1 = TimeSpan.FromDays(0.000323456); TimeSpan span2 = new TimeSpan(-2, 05, 10); TimeSpan span3 = TimeSpan.FromHours(5); Console.WriteLine("TimeSpan1 = "+span1); ... 阅读更多

C# 中的 Stack.GetEnumerator() 方法

AmitDiwan
更新于 2019年12月3日 06:47:25

73 次浏览

C# 中的 Stack.GetEnumerator() 方法用于返回 Stack 的 IEnumerator。语法语法如下:public virtual System.Collections.IEnumerator GetEnumerator ();示例让我们来看一个示例:实时演示using System; using System.Collections; public class Demo { public static void Main(){ Stack stack1 = new Stack(); stack1.Push(150); stack1.Push(300); stack1.Push(500); stack1.Push(750); stack1.Push(1000); Console.WriteLine("Stack1 elements..."); foreach(int val in stack1){ Console.WriteLine(val); } Stack stack2 = new Stack(); ... 阅读更多

C# 中的 Stack.Equals() 方法

AmitDiwan
更新于 2019年12月3日 06:44:07

267 次浏览

C# 中的 Stack.Equals() 方法用于检查 Stack 类对象是否等于另一个对象。语法语法如下:public virtual bool Equals (object ob);上述参数 ob 是与另一个对象进行比较的对象。示例让我们来看一个示例:实时演示using System; using System.Collections; public class Demo { public static void Main(){ Stack stack = new Stack(); stack.Push(150); stack.Push(300); stack.Push(500); stack.Push(750); stack.Push(1000); stack.Push(1250); stack.Push(1500); stack.Push(2000); ... 阅读更多

C# 中的 Double.IsNaN() 方法

AmitDiwan
更新于 2019年12月3日 06:39:35

613 次浏览

C# 中的 Double.IsNaN() 方法用于返回一个值,该值指示指定值是否不是数字 (NaN)。语法语法如下:public static bool IsNaN (double val);上述 val 是双精度浮点数。示例让我们来看一个示例:实时演示using System; public class Demo { public static void Main(){ double d = 1.0/0.0; Console.WriteLine("Double Value = "+d); Console.WriteLine("HashCode of Double Value = "+d.GetHashCode()); TypeCode type = d.GetTypeCode(); Console.WriteLine("TypeCode of Double Value = "+type); Console.WriteLine("Positive Infinity? = ... 阅读更多

C# 中的 TimeSpan.FromDays() 方法

AmitDiwan
更新于 2019年12月3日 06:36:56

573 次浏览

C# 中的 TimeSpan.FromDays() 方法用于返回表示指定天数的 TimeSpan,该规范精确到毫秒。语法语法如下:public static TimeSpan FromDays (double val);上述参数 val 是精确到毫秒的天数。示例让我们来看一个示例:实时演示using System; public class Demo { public static void Main(){ TimeSpan span1 = new TimeSpan(5, 25, 0); TimeSpan span2 = new TimeSpan(1, 10, 0); TimeSpan span3 = TimeSpan.FromDays(43.999999); Console.WriteLine("TimeSpan1 = "+span1); ... 阅读更多

C# BitConverter.ToUInt64 方法

AmitDiwan
更新于 2019年12月2日 12:41:46

217 次浏览

C# 中的 BitConverter.ToUInt64() 方法用于返回从字节数组中指定位置的八个字节转换而来的 64 位无符号整数。语法public static ulong ToUInt64 (byte[] val, int begnIndex);示例上述 val 是字节数组,而 begnIndex 是 val 中的起始位置。实时演示using System; public class Demo { public static void Main() { byte[] arr = { 0, 0, 1, 3, 5, 7, 9, 11, 15 }; int count = arr.Length; Console.Write("Byte Array... "); for (int i = 0; i < count; i++) { ... 阅读更多

C# BitConverter.ToUInt32() 方法

AmitDiwan
更新于 2019年12月2日 12:36:05

238 次浏览

C# 中的 BitConverter.ToUInt32() 方法用于返回从字节数组中指定位置的四个字节转换而来的 32 位无符号整数。语法public static uint ToUInt32 (byte[] val, int begnIndex);上述 val 是字节数组,而 begnIndex 是 val 中的起始位置。示例实时演示using System; public class Demo { public static void Main() { byte[] arr = { 0, 3, 5, 10, 15, 2}; int count = arr.Length; Console.Write("Byte Array... "); for (int i = 0; i < count; i++) { ... 阅读更多

C# 字符串运算符

AmitDiwan
更新于 2019年12月2日 12:31:22

500 次浏览

C# 中有两个字符串运算符:相等和不相等。示例让我们来看一个相等运算符的示例:实时演示using System; public class Demo { public static void Main() { string str1 = "Amit"; string str2 = " "; Console.WriteLine("Is string1 null or empty? = "+string.IsNullOrEmpty(str1)); Console.WriteLine("Is string2 null or empty? = "+string.IsNullOrEmpty(str2)); Console.WriteLine("Is string1 equal to str2? = "+str1 == str2); } }输出Is string1 null or empty? = False Is string2 null or empty? = False False示例让我们来看一个 C# 不等运算符的示例:实时演示using System; public class Demo { public ... 阅读更多

带示例的 C# Queue.TrimExcess() 方法

AmitDiwan
更新于 2019年12月2日 12:28:15

226 次浏览

C# 中的 Queue.TrimExcess() 方法用于将容量设置为 Queue 中元素的实际数量,如果该数量小于当前容量的 90%。语法public void TrimExcess ();示例实时演示using System; using System.Collections.Generic; public class Demo { public static void Main() { Queue queue = new Queue(); queue.Enqueue(100); queue.Enqueue(200); queue.Enqueue(300); queue.Enqueue(400); queue.Enqueue(500); queue.Enqueue(600); queue.Enqueue(700); queue.Enqueue(800); queue.Enqueue(900); queue.Enqueue(1000); Console.WriteLine("Queue..."); ... 阅读更多

带示例的 C# Object.GetType() 方法

AmitDiwan
更新于 2020年7月10日 05:04:20

3K+ 次浏览

C# 中的 Object.GetType() 方法用于获取当前实例的类型。语法语法如下:public Type GetType();示例 在线演示using System; public class Demo {    public static void Main() {       Object ob = new Object();       String str = "Jim";       Type type1 = ob.GetType();       Type type2 = str.GetType();       Console.WriteLine("Type = "+type1);       Console.WriteLine("Type = "+type2);       Console.WriteLine("Hash Code = "+type1.GetHashCode());       Console.WriteLine("Hash Code = "+type2.GetHashCode());    } }输出类型 = System.Object 类型 = System.String 哈希码 = 30015890 哈希码 = 21083178示例 在线演示using System; ... 阅读更多

广告
© . All rights reserved.