SortedList.System.Collections.IDictionary.Keys プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SortedList.System.Collections.IDictionary.Keys プロパティの意味・解説 

SortedList.System.Collections.IDictionary.Keys プロパティ

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

IDictionary のキー保持している ICollection を取得します

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

Private ReadOnly Property
 System.Collections.IDictionary.Keys As ICollection Implements
 IDictionary.Keys
Dim instance As SortedList(Of
 TKey, TValue)
Dim value As ICollection

value = CType(instance, IDictionary).Keys
ICollection IDictionary.Keys { get; }
private:
virtual property ICollection^ System.Collections.IDictionary.Keys {
    ICollection^ get () sealed = IDictionary::Keys::get;
}

プロパティ
IDictionaryキー保持している ICollection

解説解説

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

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

使用例使用例

SortedList で、System.Collections.IDictionary インターフェイスSystem.Collections.IDictionary.Keys プロパティ使用して並べ替えられたリストキー一覧表示する方法次のコード例示します。この例では、並べ替えられたリストキー/値ペア方法示しますSystem.Collections.IDictionary インターフェイス列挙子が KeyValuePair オブジェクトではなく DictionaryEntry オブジェクト返すことに注意してください

次のコード例は、System.Collections.IDictionary.Add メソッドトピック取り上げている例および出力一部分です。

Imports System
Imports System.Collections
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new sorted list of strings, with string keys,
        ' and access it using the IDictionary interface.
        '
        Dim openWith As IDictionary = _
            New sortedList(Of String,
 String)
        
        ' Add some elements to the sorted list. There are no 
        ' duplicate keys, but some of the values are duplicates.
        ' IDictionary.Add throws an exception if incorrect types
        ' are supplied for key or value.
        openWith.Add("txt", "notepad.exe")
        openWith.Add("bmp", "paint.exe")
        openWith.Add("dib", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")
<br /><span space="preserve">...</span><br
 />        ' To get the keys alone, use the Keys property.
        icoll = openWith.Keys
        
        ' The elements of the collection are strongly typed
        ' with the type that was specified for sorted list keys,
        ' even though the ICollection interface is not strongly
        ' typed.
        Console.WriteLine()
        For Each s As String
 In  icoll
            Console.WriteLine("Key = {0}", s)
        Next s
<br /><span space="preserve">...</span><br
 />        ' When you use foreach to enumerate sorted list elements
        ' with the IDictionary interface, the elements are retrieved
        ' as DictionaryEntry objects instead of KeyValuePair objects.
        Console.WriteLine()
        For Each de As DictionaryEntry
 In openWith
            Console.WriteLine("Key = {0}, Value = {1}",
 _
                de.Key, de.Value)
        Next 
<br /><span space="preserve">...</span><br
 />
    End Sub

End Class
using System;
using System.Collections;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new sorted list of strings, with string keys,
        // and access it using the IDictionary interface.
        //
        IDictionary openWith = new SortedList<string,
 string>();

        // Add some elements to the sorted list. There are no 
        // duplicate keys, but some of the values are duplicates.
        // IDictionary.Add throws an exception if incorrect types
        // are supplied for key or value.
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("dib", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");
<br /><span space="preserve">...</span><br /> 
       // To get the keys alone, use the Keys property.
        icoll = openWith.Keys;

        // The elements of the collection are strongly typed
        // with the type that was specified for keys,
        // even though the ICollection interface is not strongly
        // typed.
        Console.WriteLine();
        foreach( string s in
 icoll )
        {
            Console.WriteLine("Key = {0}", s);
        }
<br /><span space="preserve">...</span><br /> 
       // When you use foreach to enumerate sorted list elements
        // with the IDictionary interface, the elements are retrieved
        // as DictionaryEntry objects instead of KeyValuePair objects.
        Console.WriteLine();
        foreach( DictionaryEntry de in openWith
 )
        {
            Console.WriteLine("Key = {0}, Value = {1}", 
                de.Key, de.Value);
        }
<br /><span space="preserve">...</span><br /> 
   }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SortedList ジェネリック クラス
SortedList メンバ
System.Collections.Generic 名前空間
ICollection インターフェイス
SortedList.Keys プロパティ
Values


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

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

辞書ショートカット

すべての辞書の索引

SortedList.System.Collections.IDictionary.Keys プロパティのお隣キーワード
検索ランキング

   

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



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

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

©2024 GRAS Group, Inc.RSS