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

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


Valuesプロパティは、ハッシュテーブルの値を含むICollectionを取得します。

ハッシュテーブルコレクションを宣言する-

Hashtable ht = new Hashtable();

次に値を追加します

ht.Add("One", "Henry");
ht.Add("Two", "Kevin");
ht.Add("Three", "David");

ハッシュテーブルの値を表示するためのコードは次のとおりです-

using System;
using System.Collections;

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

         ht.Add("One", "Henry");
         ht.Add("Two", "Kevin");
         ht.Add("Three", "David");

         // Displaying values
         foreach (string value in ht.Values) {
            Console.WriteLine(value);
         }

         Console.ReadKey();
      }
   }
}

出力

David
Henry
Kevin

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

    Countプロパティを使用して、BitArrayクラスの要素の数をカウントします。 まず、BitArrayクラスを設定しましょう- BitArray arr = new BitArray(10); 次に、以下に示すようにCountプロパティを使用します- 例 using System; using System.Collections; public class Demo {    public static void Main() {       BitArray arr = new BitArray(10);   &n

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

    SortedListクラスの容量プロパティには、SortedListの最大サイズがあります。 SortedListのデフォルトの容量は16です。 次のコードを実行して、C#でSortedListクラスのCapacityプロパティを実装してみてください- 例 using System; using System.Collections; namespace Demo {    class Program {       static void Main(string[] args) {