Computer >> Máy Tính >  >> Lập trình >> C#

Thuộc tính IsFixedSize của lớp ArrayList trong C # là gì?

Thuộc tính IsFixedSize của lớp ArrayList được sử dụng để nhận một giá trị cho biết liệu ArrayList có kích thước cố định hay không.

Sau đây là một ví dụ nêu rõ việc sử dụng thuộc tính isFixedSize.

Ví dụ

using System;
using System.Collections;
class Demo {
   public static void Main() {
      ArrayList arrList = new ArrayList();
      Console.WriteLine("Adding some numbers:");
      arrList.Add(45);
      arrList.Add(78);
      Console.WriteLine(arrList.Count);
      Console.WriteLine("myArrayList.IsFixedSize = " + arrList.IsFixedSize);
   }
}

Đầu ra

Adding some numbers:
2
myArrayList.IsFixedSize = False

Ở trên, chúng tôi đã thêm một danh sách mảng.

ArrayList arrList = new ArrayList();

Sau đó, chúng tôi đã kiểm tra xem nó có kích thước cố định hay không.

Console.WriteLine("myArrayList.IsFixedSize = " + arrList.IsFixedSize);