SortedList.Keysとは? わかりやすく解説

SortedList.Keys プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

SortedList 内のキー格納しているコレクション取得します

名前空間: System.Collections.Generic
アセンブリ: System (system.dll 内)
構文構文

Dim instance As SortedList(Of
 TKey, TValue)
Dim value As IList(Of TKey)

value = instance.Keys
public IList<TKey> Keys { get; }
public:
property IList<TKey>^ Keys {
    IList<TKey>^ get ();
}
/** @property */
public IList<TKey> get_Keys ()

プロパティ
SortedList 内のキー格納している IList。

解説解説

IList 内のキー順序は、SortedList 内での順序と同じです。

返される IList静的コピーではありません。代わりに、この IList は、元の SortedListキー参照します。そのため、SortedList対す変更は、IList にも反映されます。

Keys プロパティによって返されるコレクション使用すると、キー効率的にインデックス取得できますリストキー内部配列単なるラッパーなので、プロパティへのアクセス時にリスト再生成する必要はありません。Keys プロパティ使用して文字列キー持つ要素並べ替えられたリストキーインデックス取得するコード例次に示します

Dim k As String = mySortedList.Keys(3)
string k = mySortedList.Keys[3];
String^ k = mySortedList->Keys[3];

このプロパティ値を取得することは、O(1) 操作なります

使用例使用例

Keys プロパティ使用して並べ替えられたリストキー列挙する方法、および並べ替えられたリストキーおよび値を列挙する方法次のコード例示します

この例では、Keys プロパティ使用してキーインデックス効率的に取得する方法示します

このコードは、コンパイルして実行することのできる例の一部です。詳細については、SortedListトピック参照してください

        ' To get the keys alone, use the Keys property.
        Dim ilistKeys As IList(Of
 String) = openWith.Keys
        
        ' The elements of the list are strongly typed with the
        ' type that was specified for the SortedList keys.
        Console.WriteLine()
        For Each s As String
 In ilistKeys 
            Console.WriteLine("Key = {0}", s)
        Next s

        ' The Keys property is an efficient way to retrieve
        ' keys by index.
        Console.WriteLine(vbLf & "Indexed retrieval using
 the " & _
            "Keys property: Keys(2) = {0}", openWith.Keys(2))
<br /><span space="preserve">...</span><br
 />        ' When you use foreach to enumerate list elements,
        ' the elements are retrieved as KeyValuePair objects.
        Console.WriteLine()
        For Each kvp As
 KeyValuePair(Of String, String)
 In openWith
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                kvp.Key, kvp.Value)
        Next kvp
        // To get the keys alone, use the Keys property.
        IList<string> ilistKeys = openWith.Keys;

        // The elements of the list are strongly typed with the 
        // type that was specified for the SortedList keys.
        Console.WriteLine();
        foreach( string s in
 ilistKeys )
        {
            Console.WriteLine("Key = {0}", s);
        }

        // The Keys property is an efficient way to retrieve
        // keys by index.
        Console.WriteLine("\nIndexed retrieval using the
 Keys " +
            "property: Keys[2] = {0}", openWith.Keys[2]);
<br /><span space="preserve">...</span><br /> 
       // When you use foreach to enumerate list elements,
        // the elements are retrieved as KeyValuePair objects.
        Console.WriteLine();
        foreach( KeyValuePair<string, string>
 kvp in openWith )
        {
            Console.WriteLine("Key = {0}, Value = {1}", 
                kvp.Key, kvp.Value);
        }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

SortedList.Keys プロパティ

SortedList 内のキー取得します

名前空間: System.Collections
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable ReadOnly
 Property Keys As ICollection
Dim instance As SortedList
Dim value As ICollection

value = instance.Keys
public virtual ICollection Keys { get; }
public:
virtual property ICollection^ Keys {
    ICollection^ get ();
}
/** @property */
public ICollection get_Keys ()

プロパティ
SortedList 内のキー格納している ICollection。

解説解説

ICollection は、SortedListキー読み取り専用ビューです。基になる SortedList変更されると、その変更はすぐに ICollection反映されます。

ICollection要素は、SortedListキーと同じ順序並べ替えられます。

GetKeyList に類似していますが、IList ではなく ICollection返します

このメソッドは O(1) 操作です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からSortedList.Keysを検索した結果を表示しています。
Weblioに収録されているすべての辞書からSortedList.Keysを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からSortedList.Keys を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SortedList.Keys」の関連用語

SortedList.Keysのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SortedList.Keysのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS