找到 34423 篇文章 编程
150 次查看
C# 中的 BitConverter.ToDouble() 方法用于返回从字节数组中指定位置的八个字节转换而来的双精度浮点数。同步语法如下:public static double ToDouble (byte[] val, int begnIndex);上面,val 是字节数组,而 begnIndex 是 val 中的起始位置。示例让我们现在看看一个例子: 在线演示using System; public class Demo { public static void Main(){ byte[] arr = { 0, 2, 5, 10, 20, 26, 34, 42, 50, 58, 66, 74, 82, 89, 97, 107, 115}; Console.WriteLine("字节数组 = {0} ", BitConverter.ToString(arr)); ... 阅读更多
188 次查看
C# 中的 BitConverter.ToInt16() 方法用于返回从字节数组中指定位置的两个字节转换而来的 16 位有符号整数。语法语法如下:public static short ToInt16 (byte[] val, int begnIndex);上面,val 是字节数组,而 begnIndex 是 val 中的起始位置。示例让我们现在看看一个例子: 在线演示using System; public class Demo { public static void Main(){ byte[] arr = { 0, 0, 7, 10, 18, 20, 25, 26, 32}; Console.WriteLine("字节数组 = {0} ", BitConverter.ToString(arr)); for (int i = 1; ... 阅读更多
65 次查看
C# 中的 Double.GetHashCode() 方法用于返回此实例的哈希代码。语法语法如下:public override int GetHashCode ();示例让我们现在看看一个例子: 在线演示using System; public class Demo { public static void Main(){ double d1 = 150d; object ob1 = 1/2; Console.WriteLine("Double1 值 = "+d1); Console.WriteLine("对象值 = "+ob1); Console.WriteLine("两个值是否相等? = "+d1.Equals(ob1)); Console.WriteLine("Double1 值的哈希码 = {0}", d1.GetHashCode()); } }输出这将产生以下输出 ... 阅读更多
68 次查看
C# 中的 Single.ToString() 方法用于将此实例的数值转换为其等效的字符串表示形式。语法语法如下:public override string ToString ();示例让我们现在看看一个例子: 在线演示using System; public class Demo { public static void Main(){ float f1 = 10.0f/0.0f; float f2 = -3.0f; Console.WriteLine("Value1(字符串表示形式) = "+f1.ToString()); Console.WriteLine("Value1 的哈希码 = "+f1.GetHashCode()); Console.WriteLine("Value1 的 TypeCode = "+f1.GetTypeCode()); Console.WriteLine("Value1 的值是正无穷大还是负无穷大? = "+Single.IsInfinity(f1)); ... 阅读更多
67 次查看
C# 中的 SortedDictionary.Item[] 属性用于获取或设置与指定键关联的值。语法语法如下:public TValue this[TKey k] { get; set; }上面,值 k 是要获取或设置的值的键。示例让我们现在看看一个例子: 在线演示using System.Collections; using System.Collections.Generic; public class Demo { public static void Main(){ SortedDictionary sortedDict = new SortedDictionary(); sortedDict.Add(1, "One"); sortedDict.Add(2, "Two"); sortedDict.Add(3, "Three"); sortedDict.Add(4, "Four"); sortedDict.Add(5, "Five"); ... 阅读更多
75 次查看
C# 中的 SortedDictionary.Count 属性用于获取 SortedDictionary 中包含的键/值对的数量。语法语法如下:public int Count { get; }示例让我们现在看看一个例子: 在线演示using System.Collections; using System.Collections.Generic; public class Demo { public static void Main(){ SortedDictionary sortedDict = new SortedDictionary(); sortedDict.Add(100, "Mobile"); sortedDict.Add(200, "Laptop"); sortedDict.Add(300, "Desktop"); sortedDict.Add(400, "Speakers"); sortedDict.Add(500, "Headphone"); sortedDict.Add(600, "Earphone"); Console.WriteLine("SortedDictionary 键值对..."); IDictionaryEnumerator demoEnum = sortedDict.GetEnumerator(); ... 阅读更多
63 次查看
C# 中的 Queue.ToArray() 方法将 Queue 元素复制到一个新的数组中。语法语法如下:public virtual object[] ToArray ();示例让我们现在看看一个例子: 在线演示using System.Collections.Generic; public class Demo { public static void Main(){ Queue queue = new Queue(); queue.Enqueue(1); queue.Enqueue(2); queue.Enqueue(3); queue.Enqueue(4); queue.Enqueue(5); Console.WriteLine("队列..."); foreach(int i in queue){ Console.WriteLine(i); } int[] intArr = queue.ToArray(); Console.WriteLine("转换 ... 阅读更多
84 次查看
C# 中的 Stack.CopyTo() 方法用于将 Stack 复制到现有的一个维度数组中,从指定的数组索引开始。语法语法如下:public virtual void CopyTo (Array arr, int index);上面,参数 arr 是从 Stack 复制的元素的目标的一维数组,而 index 是复制开始的索引。示例让我们现在看看一个例子: 在线演示using System.Collections; public class Demo { public static void Main(){ Stack stack = new Stack(); stack.Push(150); stack.Push(300); ... 阅读更多
152 次查看
C# 中的 Queue.Synchronized() 方法用于返回一个新的 Queue,该 Queue 包装原始队列并且是线程安全的。语法语法如下:public static System.Collections.Queue Synchronized (System.Collections.Queue queue);上面,参数 queue 是要同步的队列。示例让我们现在看看一个例子: 在线演示using System.Collections; public class Demo { public static void Main(){ Queue queue = new Queue(); queue.Enqueue("AB"); queue.Enqueue("BC"); queue.Enqueue("CD"); queue.Enqueue("DE"); queue.Enqueue("EF"); queue.Enqueue("FG"); queue.Enqueue("GH"); queue.Enqueue("HI"); ... 阅读更多
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP