C#
 Computer >> コンピューター >  >> プログラミング >> C#

C#のSortedListクラスのCountプロパティとは何ですか?


using System;
using System.Collections;

namespace Demo {
   class Program {
      static void Main(string[] args) {
         SortedList s = new SortedList();

         s.Add("S1", "Electronics");
         s.Add("S2", "Clothing");
         s.Add("S3", "Applicances");
         s.Add("S4", "Books");
         s.Add("S5", "Accessories");
         s.Add("S6", "Musical Instruments");

         Console.WriteLine("Count = " + s.Count);
      }
   }
}

出力

Count = 6

  1. 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 {

  2. C#のArrayListクラスのCapacityプロパティとは何ですか?

    ArrayListクラスのcapacityプロパティは、ArrayListに含めることができる要素の数を取得または設定します。 容量は常にカウントよりも大きくなります。容量プロパティの場合- arrList.Capacity デフォルトの容量は4です。5つの要素がある場合、その容量は2倍になり、8になります。これは続きます。 次のコードを実行して、C#でCapacityプロパティを実装してみてください。これは、上記で説明したことも示しています- 例 using System; using System.Collections; class Demo {    pub