找到 34423 篇文章,关于编程
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
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
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("Array elements..."); ... 阅读更多
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 ); // 显示值 ... 阅读更多
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("Value = "+val); res = Char.IsUpper(val); Console.WriteLine("Is the value an uppercae letter? = "+res); } } 输出 这将产生以下输出:Value = H Is the ... 阅读更多
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: ... 阅读更多
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("Value = "+val); res = Char.IsSymbol(val); Console.WriteLine("Is the value a symbol? = "+res); ... 阅读更多
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 = ... 阅读更多
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("String = "+val); UnicodeCategory unicode = Char.GetUnicodeCategory(val, 4); Console.WriteLine("The ... 阅读更多
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() { ... 阅读更多
数据结构
网络
关系数据库管理系统 (RDBMS)
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP