arraylist数组元素插入及显示示例
-
wisdomone1
2012-04-08 22:03:58
-
Linux操作系统
-
原创
前面几篇关于arraylist的链接:
本文关于arraylist的代码:
using System.Collections.Generic;
using System.Collections;//arraylist派生于array类
namespace ConsoleApplication1
public static void Main(string[] args)
//string str = "this is one big pig";
//Console.WriteLine(str.Substring(0));
//Console.WriteLine(str.Substring(0,str.Length));
//Console.WriteLine(str.EndsWith("x"));
//Console.WriteLine(str.EndsWith("G",StringComparison.CurrentCultureIgnoreCase));
//Console.WriteLine(str.EndsWith("G", StringComparison.CurrentCulture));
//Console.WriteLine(str.EndsWith("G", StringComparison.InvariantCulture));
//Console.WriteLine(str.EndsWith("G", StringComparison.OrdinalIgnoreCase));
ArrayList a1 = new ArrayList();
Single ss = new Single (3);
Console.WriteLine(a1.Capacity);
Console.WriteLine(a1.Count);
Console.WriteLine(a1[0]);
//如下二句代码只能分开写,不能只写一句console.writeline((Single)a1[2].name),这样是不成的
//也就是说先把arraylist的元素拆箱转换为泛型类型,然后再用泛型类型的对象的成员进行打印就可以了
Single x = (Single)a1[2];
Console.WriteLine(x.name);