找到 34423 篇文章 相关编程

C# 中的 CharEnumerator.Dispose() 方法

AmitDiwan
更新于 2019 年 11 月 4 日 09:53:38

83 次浏览

C# 中的 CharEnumerator.Dispose() 方法用于释放 CharEnumerator 类当前实例使用的所有资源。语法public void Dispose ();现在让我们看一个实现 CharEnumerator.Dispose() 方法的示例 - 示例using System; public class Demo {    public static void Main(){       string strNum = "356";       CharEnumerator ch = strNum.GetEnumerator();       while (ch.MoveNext())          Console.Write(ch.Current + " ");       // 已释放       ch.Dispose();       // 这将显示错误,因为我们在上面释放了对象       // Console.WriteLine(ch.Current);    } }输出这将产生以下输出 -3 5 6

C# 中的 CharEnumerator.Clone() 方法

AmitDiwan
更新于 2019 年 11 月 4 日 09:51:58

68 次浏览

C# 中的 CharEnumerator.Clone() 方法用于创建当前 CharEnumerator 对象的副本。语法public object Clone();现在让我们看一个实现 CharEnumerator.Clone() 方法的示例 - 示例using System; public class Demo {    public static void Main(){       string strNum = "356";       CharEnumerator ch = strNum.GetEnumerator();       while (ch.MoveNext()){          Console.Write(ch.Current + " ");          CharEnumerator enumClone = (CharEnumerator)ch.Clone();          while (enumClone.MoveNext())             Console.Write(enumClone.Current + " ");          Console.WriteLine();       }    } }输出这将产生以下输出 -3 5 6 5 6 6

C# 中的 Array.Clear() 方法

AmitDiwan
更新于 2019 年 11 月 4 日 09:50:00

295 次浏览

C# 中的 Array.Clear() 方法用于清除数组中的元素并将其设置为其默认值。元素在一个范围内被清除。语法如下 - 语法public static void Clear (Array arr, int index, int len);这里,arr 是要清除其元素的数组,index 是要清除的元素的起始索引,len 是要清除的元素的数量。现在让我们看一个实现 Array.Clear() 方法的示例 - 示例using System; public class Demo{    public static void Main(){       Console.WriteLine("数组元素...");       ... 阅读更多

C# 中的 Array.AsReadOnly(T[]) 方法

AmitDiwan
更新于 2019 年 11 月 4 日 08:16:34

164 次浏览

C# 中的 Array.AsReadOnly(T[]) 方法返回指定数组的只读包装器,它是只读的 ReadOnlyCollection。语法public static System.Collections.ObjectModel.ReadOnlyCollection AsReadOnly (T[] array);这里,T 是数组元素的类型,而数组 T[] 是一维的基于零的数组。现在让我们看一个实现 Array.AsReadOnly(T[]) 方法的示例 - 示例using System; using System.Collections.Generic; public class Demo {    public static void Main() {       String[] arr = { "John", "Tom", "Katie", "Brad" };       // 只读 IList 包装器       IList list = Array.AsReadOnly( arr );       // 显示值 ... 阅读更多

C# 中的 Char.IsUpper() 方法

AmitDiwan
更新于 2019 年 11 月 4 日 08:14:09

2K+ 次浏览

C# 中的 Char.IsUpper() 方法指示指定的 Unicode 字符是否被归类为大写字母。语法public static bool IsUpper (char ch);上面,参数 ch 是要评估的 Unicode 字符。现在让我们看一个实现 Char.IsUpper() 方法的示例 - 示例using System; public class Demo {    public static void Main(){       bool res;       char val = 'H';       Console.WriteLine("值 = "+val);       res = Char.IsUpper(val);       Console.WriteLine("值是大写字母吗? = "+res);    } }输出这将产生以下输出 -值 = H 值是大写字母吗? = True ... 阅读更多

查找给定链表中前 k 个节点的乘积(C++)

Arnab Chakraborty
更新于 2019 年 11 月 4 日 08:17:25

76 次浏览

假设我们有一个链表中有一些元素。我们必须找到前 k 个元素的乘积结果。k 的值也已给出。因此,如果列表类似于 [5, 7, 3, 5, 6, 9],并且 k = 3,则结果将为 5 * 7 * 3 = 105。过程很简单。我们只需从左侧开始读取当前元素,然后将其与 prod 相乘。(最初 prod 为 1),当遍历了 k 个元素时,停止。示例#include #include using namespace std;    class Node{       public: ... 阅读更多

C# 中的 Char.IsSymbol() 方法

AmitDiwan
更新于 2019 年 11 月 4 日 08:10:17

383 次浏览

C# 中的 Char.IsSymbol() 方法指示指定字符串中指定位置处的字符是否被归类为符号字符。语法public static bool IsSymbol (string str, int index);上面,str 是一个字符串,而 index 参数是 str 中要评估的字符的位置。现在让我们看一个实现 Char.IsSymbol() 方法的示例 - 示例using System; public class Demo {    public static void Main(){       bool res;       char val = 'P';       Console.WriteLine("值 = "+val);       res = Char.IsSymbol(val);       Console.WriteLine("值是符号吗? = "+res); ... 阅读更多

查找圆柱体的周长(C++)

Arnab Chakraborty
更新于 2019 年 11 月 4 日 08:07:19

124 次浏览

假设我们有圆柱体的直径和高度,我们必须找到圆柱体的周长。由于周长是二维物体的轮廓,因此我们无法直接找到一个三维物体的周长。我们可以对圆柱体进行横截面,并将其转换为矩形,然后找到周长。矩形横截面的两侧是直径和高度。所以周长是 -p=(2*d)+(2*h)示例#include using namespace std; int getCylinderPerimeter(int d, int h) {    return (2*d) + (2*h); } int main() {    int diameter = ... 阅读更多

C# 中的 Char.IsControl(String, Int32) 方法

AmitDiwan
更新于 2019 年 11 月 4 日 08:06:22

375 次浏览

C# 中的 Char.IsControl(String, Int32) 方法用于指示指定字符串中指定位置处的字符是否被归类为控制字符。语法public static bool IsControl (string str, int index);上面,str 是一个字符串。index 参数是 str 中要评估的字符的位置。现在让我们看一个实现 Char.IsControl(String, Int32) 方法的示例 - 示例using System; using System.Globalization; public class Demo {    public static void Main(){       string val = "hjk9878hj";       Console.WriteLine("字符串 = "+val);       UnicodeCategory unicode = Char.GetUnicodeCategory(val, 4);       Console.WriteLine("该 ... 阅读更多

查找圆内直径的另一端坐标(C++)

Arnab Chakraborty
更新于 2019 年 11 月 4 日 08:03:14

62 次浏览

假设我们有圆的中心坐标和圆周上的一个坐标点。我们必须找到圆周上的另一个点。假设中心点为 (p, q),给定点为 (a, b)。我们必须找到点 (x, y)。众所周知,圆心是直径的中点。所以我们可以写成 -(p, q)=(a+x/2, b+y/2)或者由此 (x, y) 可以表示为 -x=2p-a, y=2q-b示例#include using namespace std; int getCylinderPerimeter(int d, int h) {    return (2*d) + (2*h); } int main() {   ... 阅读更多

广告

© . All rights reserved.