//创建一个ArrayList类型变量myArrayList,并设置为只读
ArrayList myArrayList = new ArrayList(3);
ArrayList.ReadOnly(myArrayList); Console.WriteLine(myArrayList.IsFixedSize.ToString());
Console.WriteLine(myArrayList.IsReadOnly.ToString()); //分别插入“Hello”和“World!”两个字符串的myArrayList末尾
myArrayList.Add ("Hello ");
myArrayList.Add ("World!");
//输出myArrayList的容量
Console.WriteLine ("Capacity :{0}",myArrayList.Capacity); //输出myArrayList中元素的个数
Console.WriteLine ("Count :{0}",myArrayList.Count); Console.ReadLine ();
--------------------------------------------------------------
这是书上的实例。本来应该引发NotSupportException异常的,但以上代码编译时并未报错,IsFixedSize和IsReadOnly的值都为false。请问这是为什么
ArrayList myArrayList = new ArrayList(3);
ArrayList.ReadOnly(myArrayList); Console.WriteLine(myArrayList.IsFixedSize.ToString());
Console.WriteLine(myArrayList.IsReadOnly.ToString()); //分别插入“Hello”和“World!”两个字符串的myArrayList末尾
myArrayList.Add ("Hello ");
myArrayList.Add ("World!");
//输出myArrayList的容量
Console.WriteLine ("Capacity :{0}",myArrayList.Capacity); //输出myArrayList中元素的个数
Console.WriteLine ("Count :{0}",myArrayList.Count); Console.ReadLine ();
--------------------------------------------------------------
这是书上的实例。本来应该引发NotSupportException异常的,但以上代码编译时并未报错,IsFixedSize和IsReadOnly的值都为false。请问这是为什么
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/