找到 34423 篇文章,关于编程
197 次浏览
要在堆栈顶部插入对象,代码如下:示例 实时演示using System; using System.Collections.Generic; public class Demo { public static void Main() { Stack<int> stack = new Stack<int>(); stack.Push(100); stack.Push(150); stack.Push(175); stack.Push(200); stack.Push(225); stack.Push(250); Console.WriteLine("堆栈中的元素:"); foreach(var val in stack) { Console.WriteLine(val); } Console.WriteLine("堆栈中元素的数量 = "+stack.Count); ... 阅读更多
251 次浏览
要在指定索引处将元素插入 ArrayList,代码如下:示例 实时演示using System; using System.Collections; public class Demo { public static void Main() { ArrayList list = new ArrayList(); list.Add("One"); list.Add("Two"); list.Add("Three"); list.Add("Four"); list.Add("Five"); list.Add("Six"); list.Add("Seven"); list.Add("Eight"); Console.WriteLine("ArrayList 元素..."); foreach(string str in list) { Console.WriteLine(str); } Console.WriteLine("ArrayList 是只读的?... 阅读更多
92 次浏览
要获取 UInt32 值类型的 TypeCode,代码如下:示例 实时演示using System; public class Demo { public static void Main() { uint val1 = 55; uint val2 = 100; TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("val1 的 Typecode = "+type1); Console.WriteLine("val2 的 Typecode = "+type2); } }输出这将产生以下输出:val1 的 Typecode = UInt32 val2 的 Typecode = UInt32示例让我们看看另一个示例: 实时演示using System; public class Demo { ... 阅读更多
428 次浏览
要获取当前类型实现或继承的所有接口,代码如下:示例 实时演示using System; public class Demo { public static void Main() { Type type = typeof(float); Type myInterface = type.GetInterface("IFormattable", true); Type[] myInterfaces = type.GetInterfaces(); Console.WriteLine("接口 = "+myInterface); Console.WriteLine("所有接口..."); for (int i = 0; i < myInterfaces.Length; i++) Console.WriteLine(""+myInterfaces[i]); } }输出这将产生以下输出:接口 = System.IFormattable 所有接口... System.IComparable System.IFormattable System.IConvertible System.IComparable`1[System.Single] System.IEquatable`1[System.Single]让我们看看另一个示例:示例 实时... 阅读更多
87 次浏览
要获取当前类型实现或继承的特定接口,代码如下:示例 实时演示using System; public class Demo { public static void Main() { Type type = typeof(double); Type myInterface = type.GetInterface("IFormattable"); Console.WriteLine("接口 = "+myInterface); } }输出这将产生以下输出:接口 = System.IFormattable示例让我们看看另一个示例: 实时演示using System; public class Demo { public static void Main() { Type type = typeof(float); Type myInterface = type.GetInterface("IFormattable",true); Console.WriteLine("接口 = "+myInterface); } }输出这将产生以下输出:接口 = System.IFormattable
102 次浏览
要获取 UInt64 值类型的 TypeCode,代码如下:示例 实时演示using System; public class Demo { public static void Main() { ulong val1 = 55; ulong val2 = 100; TypeCode type1 = val1.GetTypeCode(); TypeCode type2 = val2.GetTypeCode(); Console.WriteLine("val1 的 Typecode = "+type1); Console.WriteLine("val2 的 Typecode = "+type2); } }输出这将产生以下输出:val1 的 Typecode = UInt64 val2 的 Typecode = UInt64示例让我们看看另一个示例:using System; public class Demo { public ... 阅读更多
370 次浏览
要检查 Dictionary 是否包含特定值,代码如下:示例 实时演示using System; using System.Collections.Generic; public class Demo { public static void Main() { Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add("One", "John"); dict.Add("Two", "Tom"); dict.Add("Three", "Jacob"); dict.Add("Four", "Kevin"); dict.Add("Five", "Nathan"); Console.WriteLine("元素的数量 = "+dict.Count); Console.WriteLine("键/值对..."); foreach(KeyValuePair<string, string> res in dict) { Console.WriteLine("键 = {0}, 值 = {1}", res.Key, res.Value); ... 阅读更多
223 次浏览
要反转整个列表中元素的顺序,代码如下所示 - 示例 在线演示使用 System; using System.Collections.Generic; public class Demo { public static void Main(String[] args) { List
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP