SortedDictionary.Keys プロパティ
アセンブリ: System (system.dll 内)

public KeyCollection Keys { get; }
public: property KeyCollection^ Keys { KeyCollection^ get (); }
/** @property */ public KeyCollection get_Keys ()
SortedDictionary 内のキーを格納している SortedDictionary.KeyCollection。

SortedDictionary.KeyCollection 内のキーは、Comparer プロパティに従って並べ替えられ、関連付けられている値が、Values プロパティから返された SortedDictionary.ValueCollection 内で並べ替えられている順序と同じです。
返される SortedDictionary.KeyCollection は静的なコピーではありません。代わりに、この SortedDictionary.KeyCollection は、元の SortedDictionary のキーを参照します。そのため、SortedDictionary に対する変更は、SortedDictionary.KeyCollection にも反映されます。

Keys プロパティを使用してディクショナリのキーを列挙する方法、およびディクショナリのキーおよび値を列挙する方法を次のコード例に示します。
このコードは、コンパイルして実行することのできる例の一部です。詳細については、SortedDictionary のトピックを参照してください。
' To get the keys alone, use the Keys property. Dim keyColl _ As SortedDictionary(Of String, String).KeyCollection = _ openWith.Keys ' The elements of the KeyCollection are strongly typed ' with the type that was specified for dictionary keys. Console.WriteLine() For Each s As String In keyColl Console.WriteLine("Key = {0}", s) Next s <br /><span space="preserve">...</span><br /> ' When you use foreach to enumerate dictionary 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. SortedDictionary<string, string>.KeyCollection keyColl = openWith.Keys; // The elements of the KeyCollection are strongly typed // with the type that was specified for dictionary keys. Console.WriteLine(); foreach( string s in keyColl ) { Console.WriteLine("Key = {0}", s); } <br /><span space="preserve">...</span><br /> // When you use foreach to enumerate dictionary 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); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


SortedDictionary ジェネリック クラス
SortedDictionary メンバ
System.Collections.Generic 名前空間
SortedDictionary.KeyCollection
Values
Weblioに収録されているすべての辞書からSortedDictionary.Keys プロパティを検索する場合は、下記のリンクをクリックしてください。

- SortedDictionary.Keys プロパティのページへのリンク