找到 34423 篇文章 关于编程

C# 中的 Random.NextBytes() 方法

AmitDiwan
更新于 2019-12-03 09:34:20

244 次浏览

C# 中的 Random.NextBytes() 方法用于用随机数填充指定的字节数组的元素。语法语法如下:public virtual void NextBytes (byte[] buffer);上面,buffer 是字节数组。示例让我们来看一个示例: 在线演示using System; public class Demo {    public static void Main(){       Random r = new Random();       Random r2 = new Random();       Random r3 = new Random();       Byte[] arr = new Byte[5];       r3.NextBytes(arr);       Console.WriteLine("随机数.....");       for (int i = 1; i

C# 中的 Queue.GetEnumerator() 方法

AmitDiwan
更新于 2019-12-03 09:26:21

85 次浏览

C# 中的 Queue.GetEnumerator() 方法用于返回一个枚举器,该枚举器遍历 Queue。语法语法如下:public virtual System.Collections.IEnumerator GetEnumerator ();示例让我们来看一个示例: 在线演示using System; using System.Collections; public class Demo {    public static void Main(){       Queue queue = new Queue();       queue.Enqueue(100);       queue.Enqueue(200);       queue.Enqueue(300);       queue.Enqueue(400);       Console.WriteLine("Queue1...");       IEnumerator demoEnum = queue.GetEnumerator();       while (demoEnum.MoveNext()){          Console.WriteLine(demoEnum.Current);       }       Queue queue2 = new Queue(); ... 阅读更多

带示例的 C# 中的 Single.IsInfinity() 方法

AmitDiwan
更新于 2019-12-03 09:23:17

89 次浏览

C# 中的 Single.IsInfinity() 方法用于返回一个值,该值指示指定数字是否计算为负无穷大或正无穷大。语法语法如下:public static bool IsInfinity (float val);上面,val 是一个单精度浮点数。示例让我们来看一个示例: 在线演示using System; public class Demo {    public static void Main(){       float f1 = 19.3f;       float f2 = Single.MaxValue;       Console.WriteLine("Value1 = "+f1);       Console.WriteLine("Value1 的哈希码 = "+f1.GetHashCode());       Console.WriteLine("Value1 的类型代码 = "+f1.GetTypeCode());       Console.WriteLine("Value1 的值是否为正或 ... 阅读更多

C# 中的 Int 64 结构

AmitDiwan
更新于 2019-12-03 09:19:44

2K+ 次浏览

Int 64 结构表示一个 64 位有符号整数。它是一个不可变的值类型,表示有符号整数,其值范围为:负 9,223,372,036,854,775,808 到正 9,223,372,036,854,775,807。以下是 Int 64 的字段:字段描述MaxValue表示 Int64 的最大可能值。此字段为常量。MinValue表示 Int64 的最小可能值。此字段为常量。以下是一些方法:字段描述CompareTo(Int64)比较此实例与指定的 64 位有符号整数,并返回其相对值的指示。CompareTo(Object)比较此实例与指定的对象,并返回其相对值的指示 ... 阅读更多

C# 中的 Insert() 方法

AmitDiwan
更新于 2019-12-03 09:14:54

752 次浏览

C# 中的 Insert() 方法用于返回一个新字符串,其中指定的字符串插入到此实例中指定的索引位置。语法语法如下:public string Insert (int begnIndex, string val);上面,参数 begnIndex 是插入操作的基于零的索引位置,而 val 是要插入的字符串。示例让我们来看一个示例: 在线演示using System; public class Demo{    public static void Main(){       String str = "JohnWick";       Console.WriteLine("初始字符串 = "+str);       String res = str.Insert(5, " ");       Console.WriteLine("更新后的 = ... 阅读更多

C# 中的 Random.NextDouble() 方法

AmitDiwan
更新于 2019-12-03 09:12:56

743 次浏览

C# 中的 Random.NextDouble() 方法用于返回一个大于或等于 0.0 且小于 1.0 的随机浮点数。语法语法如下:public virtual double NextDouble ();示例让我们来看一个示例: 在线演示using System; public class Demo {    public static void Main(){       Random r1 = new Random();       Random r2 = new Random();       Byte[] arr = new Byte[2];       r1.NextBytes(arr);       Console.WriteLine("字节数组中的随机数...");       for (int i = 0; i < 2; i++) ... 阅读更多

C# 中的 SortedDictionary.Remove() 方法

AmitDiwan
更新于 2019-12-03 08:19:23

92 次浏览

C# 中的 SortedDictionary.Remove() 方法用于从 SortedDictionary 中删除具有指定键的元素。输出语法如下:public bool Remove (TKey key);上面,参数 key 是要删除的元素的键。示例让我们来看一个示例: 在线演示using System; 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");       ... 阅读更多

C# 中的 SortedDictionary.Keys 属性

AmitDiwan
更新于 2019-12-03 08:16:32

189 次浏览

C# 中的 SortedDictionary.Keys 属性用于获取包含 SortedDictionary 中键的集合。语法语法如下:public System.Collections.Generic.SortedDictionary.KeyCollection Keys { get; }示例让我们来看一个示例: 在线演示using System; using System.Collections; using System.Collections.Generic; public class Demo {    public static void Main(){       SortedDictionary sortedDict = new SortedDictionary();       sortedDict.Add(1, "SUV");       sortedDict.Add(2, "MUV");       sortedDict.Add(3, "Utility Vehicle");       sortedDict.Add(4, "AUV");       sortedDict.Add(5, "Hatchback");       sortedDict.Add(6, "Convertible");       Console.WriteLine("SortedDictionary 键值对...");       IDictionaryEnumerator demoEnum = sortedDict.GetEnumerator(); ... 阅读更多

带示例的 C# 中的 SByte.ToString() 方法

AmitDiwan
更新于 2019-12-03 08:12:44

339 次浏览

C# 中的 SByte.ToString() 方法用于将此实例的数值转换为其等效的字符串表示形式。语法语法如下:public override string ToString ();示例让我们来看一个示例: 在线演示using System; public class Demo {    public static void Main(){       sbyte s1 = 10;       sbyte s2 = 100;       Console.WriteLine("S1 的值 = "+s1);       Console.WriteLine("S2 的值 = "+s2);       int res = s1.CompareTo(s2);       if (res > 0)          Console.WriteLine("s1 > s2");       ... 阅读更多

C# 中的 BitConverter.ToInt32() 方法

AmitDiwan
更新于 2019-12-03 08:08:52

336 次浏览

C# 中的 BitConverter.ToInt32() 方法用于返回从字节数组中指定位置的四个字节转换的 32 位有符号整数。语法语法如下:public static int ToInt32 (byte[] val, int begnIndex);上面,val 是字节数组,而 begnIndex 是 val 中的起始位置。示例让我们来看一个示例: 在线演示using System; public class Demo {    public static void Main(){       byte[] arr = { 10, 20, 30, 40, 50};       Console.WriteLine("字节数组 = {0} ", BitConverter.ToString(arr));       for (int i = 1; i < arr.Length - ... 阅读更多

广告
© . All rights reserved.