C#のArrayListクラスのCountプロパティとは何ですか?
ArrayListクラスのCountプロパティは、ArrayListの要素の数をカウントします。
まず、ArrayListに要素を追加します-
ArrayList arrList = new ArrayList(); arrList.Add(98); arrList.Add(55); arrList.Add(65); arrList.Add(34);
次に、配列リストの数を取得します-
arrList.Count
以下は、C#でCountプロパティを実装するためのコードです-
例
using System;
using System.Collections;
class Demo {
public static void Main() {
ArrayList arrList = new ArrayList();
arrList.Add(98);
arrList.Add(55);
arrList.Add(65);
arrList.Add(34);
Console.WriteLine("Count = " + arrList.Count);
}
} 出力
Count = 4
-
C#のArrayListクラスのCountプロパティとは何ですか?
ArrayListクラスのCountプロパティは、ArrayListの要素の数をカウントします。 まず、ArrayListに要素を追加します- ArrayList arrList = new ArrayList(); arrList.Add(98); arrList.Add(55); arrList.Add(65); arrList.Add(34); 次に、配列リストの数を取得します- arrList.Count 以下は、C#でCountプロパティを実装するためのコードです- 例 using System; using System.Collections; class Demo {
-
C#のArrayListクラスのCapacityプロパティとは何ですか?
ArrayListクラスのcapacityプロパティは、ArrayListに含めることができる要素の数を取得または設定します。 容量は常にカウントよりも大きくなります。容量プロパティの場合- arrList.Capacity デフォルトの容量は4です。5つの要素がある場合、その容量は2倍になり、8になります。これは続きます。 次のコードを実行して、C#でCapacityプロパティを実装してみてください。これは、上記で説明したことも示しています- 例 using System; using System.Collections; class Demo { pub