ArrayList的FixedSize方法返回具有固定大小的ArrayList包装器。
C# ArrayList中的FixedSize方法示例
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
//Creates a new ArrayList.
ArrayList arraylist = new ArrayList();
arraylist.Add("One");
arraylist.Add("Two");
arraylist.Add("Three");
arraylist.Add("Four");
arraylist.Add("Five");
arraylist.Add("Six");
arraylist.Add("Seven");
arraylist.Add("Eight");
arraylist.Add("Nine");
//Create a fixed-size ArrayList.
ArrayList FixedSize = ArrayList.FixedSize(arraylist);
//Display whether the ArrayLists have a fixed size or not.
Console.WriteLine("ArrayList {0}.", arraylist.IsFixedSize ? "has a fixed size" : "does not have a fixed size");
Console.WriteLine("FixedSize {0}.", FixedSize.IsFixedSize ? "has a fixed size" : "does not have a fixed size");
Console.WriteLine();
}
}
}
日期:2020-04-11 22:50:30 来源:oir作者:oir
