NameObjectCollectionBase NameObjectCollectionBase NameObjectCollectionBase NameObjectCollectionBase Class

定義

String キーと、キーまたはインデックスを使用してアクセスできる Object 値が関連付けられたコレクションの abstract 基本クラスを指定します。Provides the abstract base class for a collection of associated String keys and Object values that can be accessed either with the key or with the index.

public ref class NameObjectCollectionBase abstract : System::Collections::ICollection, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[System.Serializable]
public abstract class NameObjectCollectionBase : System.Collections.ICollection, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type NameObjectCollectionBase = class
    interface ICollection
    interface ISerializable
    interface IDeserializationCallback
    interface IEnumerable
Public MustInherit Class NameObjectCollectionBase
Implements ICollection, IDeserializationCallback, ISerializable
継承
NameObjectCollectionBaseNameObjectCollectionBaseNameObjectCollectionBaseNameObjectCollectionBase
派生
属性
実装

NameObjectCollectionBaseクラスを実装して使用する方法を次のコード例に示します。The following code example shows how to implement and use the NameObjectCollectionBase class.

#using <System.dll>
using namespace System;
using namespace System::Collections;
using namespace System::Collections::Specialized;

public ref class MyCollection : public NameObjectCollectionBase  {

private:
   DictionaryEntry^ _de;

   // Creates an empty collection.
public:
   MyCollection()  {
      _de = gcnew DictionaryEntry();
   }

   // Adds elements from an IDictionary into the new collection.
   MyCollection( IDictionary^ d, Boolean bReadOnly )  {

      _de = gcnew DictionaryEntry();

      for each ( DictionaryEntry^ de in d )  {
         this->BaseAdd( (String^) de->Key, de->Value );
      }
      this->IsReadOnly = bReadOnly;
   }

   // Gets a key-and-value pair (DictionaryEntry) using an index.
   property DictionaryEntry^ default[ int ]  {
      DictionaryEntry^ get(int index)  {
         _de->Key = this->BaseGetKey(index);
         _de->Value = this->BaseGet(index);
         return( _de );
      }
   }

   // Gets or sets the value associated with the specified key.
   property Object^ default[ String^ ]  {
      Object^ get(String^ key)  {
         return( this->BaseGet( key ) );
      }
      void set( String^ key, Object^ value )  {
         this->BaseSet( key, value );
      }
   }

   // Gets a String array that contains all the keys in the collection.
   property array<String^>^ AllKeys  {
      array<String^>^ get()  {
         return( (array<String^>^)this->BaseGetAllKeys() );
      }
   }

   // Gets an Object array that contains all the values in the collection.
   property Array^ AllValues  {
      Array^ get()  {
         return( this->BaseGetAllValues() );
      }
   }

   // Gets a String array that contains all the values in the collection.
   property array<String^>^ AllStringValues  {
      array<String^>^ get()  {
         return( (array<String^>^) this->BaseGetAllValues(  String ::typeid ));
      }
   }

   // Gets a value indicating if the collection contains keys that are not null.
   property Boolean HasKeys  {
      Boolean get()  {
         return( this->BaseHasKeys() );
      }
   }

   // Adds an entry to the collection.
   void Add( String^ key, Object^ value )  {
      this->BaseAdd( key, value );
   }

   // Removes an entry with the specified key from the collection.
   void Remove( String^ key )  {
      this->BaseRemove( key );
   }

   // Removes an entry in the specified index from the collection.
   void Remove( int index )  {
      this->BaseRemoveAt( index );
   }

   // Clears all the elements in the collection.
   void Clear()  {
      this->BaseClear();
   }
};

public ref class SamplesNameObjectCollectionBase  {

public:
   static void Main()  {
      // Creates and initializes a new MyCollection that is read-only.
      IDictionary^ d = gcnew ListDictionary();
      d->Add( "red", "apple" );
      d->Add( "yellow", "banana" );
      d->Add( "green", "pear" );
      MyCollection^ myROCol = gcnew MyCollection( d, true );

      // Tries to add a new item.
      try  {
         myROCol->Add( "blue", "sky" );
      }
      catch ( NotSupportedException^ e )  {
         Console::WriteLine( e->ToString() );
      }

      // Displays the keys and values of the MyCollection.
      Console::WriteLine( "Read-Only Collection:" );
      PrintKeysAndValues( myROCol );

      // Creates and initializes an empty MyCollection that is writable.
      MyCollection^ myRWCol = gcnew MyCollection();

      // Adds new items to the collection.
      myRWCol->Add( "purple", "grape" );
      myRWCol->Add( "orange", "tangerine" );
      myRWCol->Add( "black", "berries" );
      Console::WriteLine( "Writable Collection (after adding values):" );
      PrintKeysAndValues( myRWCol );

      // Changes the value of one element.
      myRWCol["orange"] = "grapefruit";
      Console::WriteLine( "Writable Collection (after changing one value):" );
      PrintKeysAndValues( myRWCol );

      // Removes one item from the collection.
      myRWCol->Remove( "black" );
      Console::WriteLine( "Writable Collection (after removing one value):" );
      PrintKeysAndValues( myRWCol );

      // Removes all elements from the collection.
      myRWCol->Clear();
      Console::WriteLine( "Writable Collection (after clearing the collection):" );
      PrintKeysAndValues( myRWCol );
   }

   // Prints the indexes, keys, and values.
   static void PrintKeysAndValues( MyCollection^ myCol )  {
      for ( int i = 0; i < myCol->Count; i++ )  {
         Console::WriteLine( "[{0}] : {1}, {2}", i, myCol[i]->Key, myCol[i]->Value );
      }
   }

   // Prints the keys and values using AllKeys.
   static void PrintKeysAndValues2( MyCollection^ myCol )  {
      for each ( String^ s in myCol->AllKeys )  {
         Console::WriteLine( "{0}, {1}", s, myCol[s] );
      }
   }
};

int main()
{
    SamplesNameObjectCollectionBase::Main();
}

/*
This code produces the following output.

System.NotSupportedException: Collection is read-only.
   at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value)
   at SamplesNameObjectCollectionBase.Main()
Read-Only Collection:
[0] : red, apple
[1] : yellow, banana
[2] : green, pear
Writable Collection (after adding values):
[0] : purple, grape
[1] : orange, tangerine
[2] : black, berries
Writable Collection (after changing one value):
[0] : purple, grape
[1] : orange, grapefruit
[2] : black, berries
Writable Collection (after removing one value):
[0] : purple, grape
[1] : orange, grapefruit
Writable Collection (after clearing the collection):

*/
using System;
using System.Collections;
using System.Collections.Specialized;

public class MyCollection : NameObjectCollectionBase
{
   // Creates an empty collection.
   public MyCollection()  {
   }

   // Adds elements from an IDictionary into the new collection.
   public MyCollection( IDictionary d, Boolean bReadOnly )  {
      foreach ( DictionaryEntry de in d )  {
         this.BaseAdd( (String) de.Key, de.Value );
      }
      this.IsReadOnly = bReadOnly;
   }

   // Gets a key-and-value pair (DictionaryEntry) using an index.
   public DictionaryEntry this[ int index ]  {
      get  {
          return ( new DictionaryEntry( 
              this.BaseGetKey(index), this.BaseGet(index) ) );
      }
   }

   // Gets or sets the value associated with the specified key.
   public Object this[ String key ]  {
      get  {
         return( this.BaseGet( key ) );
      }
      set  {
         this.BaseSet( key, value );
      }
   }

   // Gets a String array that contains all the keys in the collection.
   public String[] AllKeys  {
      get  {
         return( this.BaseGetAllKeys() );
      }
   }

   // Gets an Object array that contains all the values in the collection.
   public Array AllValues  {
      get  {
         return( this.BaseGetAllValues() );
      }
   }

   // Gets a String array that contains all the values in the collection.
   public String[] AllStringValues  {
      get  {
         return( (String[]) this.BaseGetAllValues( typeof( string ) ));
      }
   }

   // Gets a value indicating if the collection contains keys that are not null.
   public Boolean HasKeys  {
      get  {
         return( this.BaseHasKeys() );
      }
   }

   // Adds an entry to the collection.
   public void Add( String key, Object value )  {
      this.BaseAdd( key, value );
   }

   // Removes an entry with the specified key from the collection.
   public void Remove( String key )  {
      this.BaseRemove( key );
   }

   // Removes an entry in the specified index from the collection.
   public void Remove( int index )  {
      this.BaseRemoveAt( index );
   }

   // Clears all the elements in the collection.
   public void Clear()  {
      this.BaseClear();
   }

}

public class SamplesNameObjectCollectionBase  {

   public static void Main()  {

      // Creates and initializes a new MyCollection that is read-only.
      IDictionary d = new ListDictionary();
      d.Add( "red", "apple" );
      d.Add( "yellow", "banana" );
      d.Add( "green", "pear" );
      MyCollection myROCol = new MyCollection( d, true );

      // Tries to add a new item.
      try  {
         myROCol.Add( "blue", "sky" );
      }
      catch ( NotSupportedException e )  {
         Console.WriteLine( e.ToString() );
      }

      // Displays the keys and values of the MyCollection.
      Console.WriteLine( "Read-Only Collection:" );
      PrintKeysAndValues( myROCol );


      // Creates and initializes an empty MyCollection that is writable.
      MyCollection myRWCol = new MyCollection();

      // Adds new items to the collection.
      myRWCol.Add( "purple", "grape" );
      myRWCol.Add( "orange", "tangerine" );
      myRWCol.Add( "black", "berries" );
      Console.WriteLine( "Writable Collection (after adding values):" );
      PrintKeysAndValues( myRWCol );

      // Changes the value of one element.
      myRWCol["orange"] = "grapefruit";
      Console.WriteLine( "Writable Collection (after changing one value):" );
      PrintKeysAndValues( myRWCol );

      // Removes one item from the collection.
      myRWCol.Remove( "black" );
      Console.WriteLine( "Writable Collection (after removing one value):" );
      PrintKeysAndValues( myRWCol );

      // Removes all elements from the collection.
      myRWCol.Clear();
      Console.WriteLine( "Writable Collection (after clearing the collection):" );
      PrintKeysAndValues( myRWCol );

   }

   // Prints the indexes, keys, and values.
   public static void PrintKeysAndValues( MyCollection myCol )  {
      for ( int i = 0; i < myCol.Count; i++ )  {
         Console.WriteLine( "[{0}] : {1}, {2}", i, myCol[i].Key, myCol[i].Value );
      }
   }

   // Prints the keys and values using AllKeys.
   public static void PrintKeysAndValues2( MyCollection myCol )  {
      foreach ( String s in myCol.AllKeys )  {
         Console.WriteLine( "{0}, {1}", s, myCol[s] );
      }
   }
}


/*
This code produces the following output.

System.NotSupportedException: Collection is read-only.
   at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value)
   at SamplesNameObjectCollectionBase.Main()
Read-Only Collection:
[0] : red, apple
[1] : yellow, banana
[2] : green, pear
Writable Collection (after adding values):
[0] : purple, grape
[1] : orange, tangerine
[2] : black, berries
Writable Collection (after changing one value):
[0] : purple, grape
[1] : orange, grapefruit
[2] : black, berries
Writable Collection (after removing one value):
[0] : purple, grape
[1] : orange, grapefruit
Writable Collection (after clearing the collection):

*/
Imports System.Collections
Imports System.Collections.Specialized

Public Class MyCollection
   Inherits NameObjectCollectionBase

   ' Creates an empty collection.
   Public Sub New()
   End Sub

   ' Adds elements from an IDictionary into the new collection.
   Public Sub New(d As IDictionary, bReadOnly As Boolean)
      Dim de As DictionaryEntry
      For Each de In  d
         Me.BaseAdd(CType(de.Key, String), de.Value)
      Next de
      Me.IsReadOnly = bReadOnly
   End Sub

   ' Gets a key-and-value pair (DictionaryEntry) using an index.
   Default Public ReadOnly Property Item(index As Integer) As DictionaryEntry
      Get
            return new DictionaryEntry( _
                me.BaseGetKey(index), me.BaseGet(index) )
      End Get
   End Property

   ' Gets or sets the value associated with the specified key.
   Default Public Property Item(key As String) As Object
      Get
         Return Me.BaseGet(key)
      End Get
      Set
         Me.BaseSet(key, value)
      End Set
   End Property

   ' Gets a String array that contains all the keys in the collection.
   Public ReadOnly Property AllKeys() As String()
      Get
         Return Me.BaseGetAllKeys()
      End Get
   End Property

   ' Gets an Object array that contains all the values in the collection.
   Public ReadOnly Property AllValues() As Array
      Get
         Return Me.BaseGetAllValues()
      End Get
   End Property

   ' Gets a String array that contains all the values in the collection.
   Public ReadOnly Property AllStringValues() As String()
      Get
         Return CType(Me.BaseGetAllValues(GetType(String)), String())
      End Get
   End Property

   ' Gets a value indicating if the collection contains keys that are not null.
   Public ReadOnly Property HasKeys() As Boolean
      Get
         Return Me.BaseHasKeys()
      End Get
   End Property

   ' Adds an entry to the collection.
   Public Sub Add(key As String, value As Object)
      Me.BaseAdd(key, value)
   End Sub

   ' Removes an entry with the specified key from the collection.
   Overloads Public Sub Remove(key As String)
      Me.BaseRemove(key)
   End Sub

   ' Removes an entry in the specified index from the collection.
   Overloads Public Sub Remove(index As Integer)
      Me.BaseRemoveAt(index)
   End Sub

   ' Clears all the elements in the collection.
   Public Sub Clear()
      Me.BaseClear()
   End Sub

End Class


Public Class SamplesNameObjectCollectionBase   

   Public Shared Sub Main()

      ' Creates and initializes a new MyCollection that is read-only.
      Dim d As New ListDictionary()
      d.Add("red", "apple")
      d.Add("yellow", "banana")
      d.Add("green", "pear")
      Dim myROCol As New MyCollection(d, True)

      ' Tries to add a new item.
      Try
         myROCol.Add("blue", "sky")
      Catch e As NotSupportedException
         Console.WriteLine(e.ToString())
      End Try

      ' Displays the keys and values of the MyCollection.
      Console.WriteLine("Read-Only Collection:")
      PrintKeysAndValues(myROCol)

      ' Creates and initializes an empty MyCollection that is writable.
      Dim myRWCol As New MyCollection()

      ' Adds new items to the collection.
      myRWCol.Add("purple", "grape")
      myRWCol.Add("orange", "tangerine")
      myRWCol.Add("black", "berries")
      Console.WriteLine("Writable Collection (after adding values):")
      PrintKeysAndValues(myRWCol)

      ' Changes the value of one element.
      myRWCol("orange") = "grapefruit"
      Console.WriteLine("Writable Collection (after changing one value):")
      PrintKeysAndValues(myRWCol)

      ' Removes one item from the collection.
      myRWCol.Remove("black")
      Console.WriteLine("Writable Collection (after removing one value):")
      PrintKeysAndValues(myRWCol)

      ' Removes all elements from the collection.
      myRWCol.Clear()
      Console.WriteLine("Writable Collection (after clearing the collection):")
      PrintKeysAndValues(myRWCol)

   End Sub

   ' Prints the indexes, keys, and values.
   Public Shared Sub PrintKeysAndValues(myCol As MyCollection)
      Dim i As Integer
      For i = 0 To myCol.Count - 1
         Console.WriteLine("[{0}] : {1}, {2}", i, myCol(i).Key, myCol(i).Value)
      Next i
   End Sub

   ' Prints the keys and values using AllKeys.
   Public Shared Sub PrintKeysAndValues2(myCol As MyCollection)
      Dim s As String
      For Each s In  myCol.AllKeys
         Console.WriteLine("{0}, {1}", s, myCol(s))
      Next s
   End Sub

End Class


'This code produces the following output.
'
'System.NotSupportedException: Collection is read-only.
'   at System.Collections.Specialized.NameObjectCollectionBase.BaseAdd(String name, Object value)
'   at SamplesNameObjectCollectionBase.Main()
'Read-Only Collection:
'[0] : red, apple
'[1] : yellow, banana
'[2] : green, pear
'Writable Collection (after adding values):
'[0] : purple, grape
'[1] : orange, tangerine
'[2] : black, berries
'Writable Collection (after changing one value):
'[0] : purple, grape
'[1] : orange, grapefruit
'[2] : black, berries
'Writable Collection (after removing one value):
'[0] : purple, grape
'[1] : orange, grapefruit
'Writable Collection (after clearing the collection):

注釈

このクラスの基になる構造は、ハッシュテーブルです。The underlying structure for this class is a hash table.

各要素は、キーと値のペアです。Each element is a key/value pair.

NameObjectCollectionBaseの容量は、NameObjectCollectionBaseが保持できる要素の数です。The capacity of a NameObjectCollectionBase is the number of elements the NameObjectCollectionBase can hold. 要素がにNameObjectCollectionBase追加されると、再割り当てによって必要に応じて容量が自動的に増加します。As elements are added to a NameObjectCollectionBase, the capacity is automatically increased as required through reallocation.

ハッシュコードプロバイダーは、 NameObjectCollectionBaseインスタンス内のキーのハッシュコードを省きします。The hash code provider dispenses hash codes for keys in the NameObjectCollectionBase instance. 既定のハッシュ コード プロバイダーは、CaseInsensitiveHashCodeProviderです。The default hash code provider is the CaseInsensitiveHashCodeProvider.

比較演算子は、2 つのキーが等しいかどうかを判断します。The comparer determines whether two keys are equal. 既定の比較子はCaseInsensitiveComparerです。The default comparer is the CaseInsensitiveComparer.

.NET Framework バージョン1.0 では、このクラスはカルチャに依存した文字列比較を使用します。In .NET Framework version 1.0, this class uses culture-sensitive string comparisons. ただし、.NET Framework バージョン1.1 以降では、このクラスはCultureInfo.InvariantCulture文字列を比較するときにを使用します。However, in .NET Framework version 1.1 and later, this class uses CultureInfo.InvariantCulture when comparing strings. 比較と並べ替えのカルチャのしくみの詳細については、次を参照してくださいカルチャを認識しない文字列操作を実行するFor more information about how culture affects comparisons and sorting, see Performing Culture-Insensitive String Operations.

キーまたは値としてnullを許可します。null is allowed as a key or as a value.

注意事項

BaseGetメソッドは、指定したキーが見つからないために返されたnullと、キーに関連付けられている値がnullであるために返されたnullを区別しません。The BaseGet method does not distinguish between null which is returned because the specified key is not found and null which is returned because the value associated with the key is null.

コンストラクター

NameObjectCollectionBase() NameObjectCollectionBase() NameObjectCollectionBase() NameObjectCollectionBase()

NameObjectCollectionBase クラスの新しい空のインスタンスを初期化します。Initializes a new instance of the NameObjectCollectionBase class that is empty.

NameObjectCollectionBase(IEqualityComparer) NameObjectCollectionBase(IEqualityComparer) NameObjectCollectionBase(IEqualityComparer) NameObjectCollectionBase(IEqualityComparer)

空で、既定の初期量を備え、指定した NameObjectCollectionBase オブジェクトを使用する、IEqualityComparer クラスの新しいインスタンスを初期化します。Initializes a new instance of the NameObjectCollectionBase class that is empty, has the default initial capacity, and uses the specified IEqualityComparer object.

NameObjectCollectionBase(IHashCodeProvider, IComparer) NameObjectCollectionBase(IHashCodeProvider, IComparer) NameObjectCollectionBase(IHashCodeProvider, IComparer) NameObjectCollectionBase(IHashCodeProvider, IComparer)

空で、既定の初期量を備え、指定したハッシュ コード プロバイダーと指定した比較子を使用する、NameObjectCollectionBase クラスの新しいインスタンスを初期化します。Initializes a new instance of the NameObjectCollectionBase class that is empty, has the default initial capacity, and uses the specified hash code provider and the specified comparer.

NameObjectCollectionBase(Int32) NameObjectCollectionBase(Int32) NameObjectCollectionBase(Int32) NameObjectCollectionBase(Int32)

空で、指定した初期量を備え、既定のハッシュ コード プロバイダーと既定の比較子を使用する、NameObjectCollectionBase クラスの新しいインスタンスを初期化します。Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity, and uses the default hash code provider and the default comparer.

NameObjectCollectionBase(Int32, IEqualityComparer) NameObjectCollectionBase(Int32, IEqualityComparer) NameObjectCollectionBase(Int32, IEqualityComparer) NameObjectCollectionBase(Int32, IEqualityComparer)

空で、指定した初期量を備え、指定した IEqualityComparer オブジェクトを使用する、NameObjectCollectionBase クラスの新しいインスタンスを初期化します。Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity, and uses the specified IEqualityComparer object.

NameObjectCollectionBase(Int32, IHashCodeProvider, IComparer) NameObjectCollectionBase(Int32, IHashCodeProvider, IComparer) NameObjectCollectionBase(Int32, IHashCodeProvider, IComparer) NameObjectCollectionBase(Int32, IHashCodeProvider, IComparer)

空で、指定した初期量を備え、指定したハッシュ コード プロバイダーと指定した比較子を使用する、NameObjectCollectionBase クラスの新しいインスタンスを初期化します。Initializes a new instance of the NameObjectCollectionBase class that is empty, has the specified initial capacity and uses the specified hash code provider and the specified comparer.

NameObjectCollectionBase(SerializationInfo, StreamingContext) NameObjectCollectionBase(SerializationInfo, StreamingContext) NameObjectCollectionBase(SerializationInfo, StreamingContext) NameObjectCollectionBase(SerializationInfo, StreamingContext)

シリアル化でき、指定した SerializationInfoStreamingContext を使用する、NameObjectCollectionBase クラスの新しいインスタンスを初期化します。Initializes a new instance of the NameObjectCollectionBase class that is serializable and uses the specified SerializationInfo and StreamingContext.

プロパティ

Count Count Count Count

NameObjectCollectionBase インスタンスに格納されているキーと値のペアの数を取得します。Gets the number of key/value pairs contained in the NameObjectCollectionBase instance.

IsReadOnly IsReadOnly IsReadOnly IsReadOnly

NameObjectCollectionBase インスタンスが読み取り専用かどうかを示す値を取得または設定します。Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only.

Keys Keys Keys Keys

NameObjectCollectionBase インスタンス内のすべてのキーを格納する NameObjectCollectionBase.KeysCollection インスタンスを取得します。Gets a NameObjectCollectionBase.KeysCollection instance that contains all the keys in the NameObjectCollectionBase instance.

メソッド

BaseAdd(String, Object) BaseAdd(String, Object) BaseAdd(String, Object) BaseAdd(String, Object)

指定したキーと値を持つエントリを NameObjectCollectionBase インスタンスに追加します。Adds an entry with the specified key and value into the NameObjectCollectionBase instance.

BaseClear() BaseClear() BaseClear() BaseClear()

NameObjectCollectionBase インスタンスからすべてのエントリを削除します。Removes all entries from the NameObjectCollectionBase instance.

BaseGet(Int32) BaseGet(Int32) BaseGet(Int32) BaseGet(Int32)

NameObjectCollectionBase インスタンスの指定したインデックスにあるエントリの値を取得します。Gets the value of the entry at the specified index of the NameObjectCollectionBase instance.

BaseGet(String) BaseGet(String) BaseGet(String) BaseGet(String)

NameObjectCollectionBase インスタンスから、指定したキーを持つ最初のエントリの値を取得します。Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance.

BaseGetAllKeys() BaseGetAllKeys() BaseGetAllKeys() BaseGetAllKeys()

NameObjectCollectionBase インスタンス内のすべてのキーを格納する String 配列を返します。Returns a String array that contains all the keys in the NameObjectCollectionBase instance.

BaseGetAllValues() BaseGetAllValues() BaseGetAllValues() BaseGetAllValues()

NameObjectCollectionBase インスタンス内のすべての値を格納する Object 配列を返します。Returns an Object array that contains all the values in the NameObjectCollectionBase instance.

BaseGetAllValues(Type) BaseGetAllValues(Type) BaseGetAllValues(Type) BaseGetAllValues(Type)

NameObjectCollectionBase インスタンス内のすべての値を格納する、指定した型の配列を返します。Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance.

BaseGetKey(Int32) BaseGetKey(Int32) BaseGetKey(Int32) BaseGetKey(Int32)

NameObjectCollectionBase インスタンスの指定したインデックスにあるエントリのキーを取得します。Gets the key of the entry at the specified index of the NameObjectCollectionBase instance.

BaseHasKeys() BaseHasKeys() BaseHasKeys() BaseHasKeys()

NameObjectCollectionBase インスタンスが、キーが null ではないエントリを格納しているかどうかを示す値を取得します。Gets a value indicating whether the NameObjectCollectionBase instance contains entries whose keys are not null.

BaseRemove(String) BaseRemove(String) BaseRemove(String) BaseRemove(String)

指定したキーを持つエントリを NameObjectCollectionBase インスタンスから削除します。Removes the entries with the specified key from the NameObjectCollectionBase instance.

BaseRemoveAt(Int32) BaseRemoveAt(Int32) BaseRemoveAt(Int32) BaseRemoveAt(Int32)

NameObjectCollectionBase インスタンスの指定したインデックスにあるエントリを削除します。Removes the entry at the specified index of the NameObjectCollectionBase instance.

BaseSet(Int32, Object) BaseSet(Int32, Object) BaseSet(Int32, Object) BaseSet(Int32, Object)

NameObjectCollectionBase インスタンスの指定したインデックスにあるエントリの値を設定します。Sets the value of the entry at the specified index of the NameObjectCollectionBase instance.

BaseSet(String, Object) BaseSet(String, Object) BaseSet(String, Object) BaseSet(String, Object)

NameObjectCollectionBase インスタンス内に指定したキーを持つエントリが存在する場合は、その最初のエントリの値を設定します。存在しない場合は、指定したキーと値を持つエントリを NameObjectCollectionBase インスタンスに追加します。Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

NameObjectCollectionBase を反復処理する列挙子を返します。Returns an enumerator that iterates through the NameObjectCollectionBase.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

ISerializable インターフェイスを実装し、NameObjectCollectionBase インスタンスをシリアル化するために必要なデータを返します。Implements the ISerializable interface and returns the data needed to serialize the NameObjectCollectionBase instance.

GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)
OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object)

ISerializable インターフェイスを実装し、逆シリアル化が完了したときに逆シリアル化イベントを発生させます。Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.

ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

明示的なインターフェイスの実装

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

NameObjectCollectionBase 全体を、互換性のある 1 次元の Array にコピーします。コピー操作は、コピー先の配列の指定したインデックスから始まる部分に行います。Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

NameObjectCollectionBase オブジェクトへのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe).

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

NameObjectCollectionBase オブジェクトへのアクセスを同期するために使用できるオブジェクトを取得します。Gets an object that can be used to synchronize access to the NameObjectCollectionBase object.

拡張メソッド

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable の要素を、指定した型にキャストします。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

指定された型に基づいて IEnumerable の要素をフィルター処理します。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

クエリの並列化を有効にします。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerableIQueryable に変換します。Converts an IEnumerable to an IQueryable.

適用対象

スレッド セーフ

パブリック静的 (Visual Basic ではShared) なこの型のメンバーはスレッド セーフですPublic static (Shared in Visual Basic) members of this type are thread safe. インスタンス メンバーの場合は、スレッド セーフであるとは限りません。Any instance members are not guaranteed to be thread safe.

この実装は、 NameObjectCollectionBaseに対して同期された (スレッドセーフな) ラッパーを提供しませんが、派生クラスはSyncRootプロパティを使用して、 NameObjectCollectionBase独自の同期バージョンを作成できます。This implementation does not provide a synchronized (thread safe) wrapper for a NameObjectCollectionBase, but derived classes can create their own synchronized versions of the NameObjectCollectionBase using the SyncRoot property.

コレクションの列挙は、本質的にスレッド セーフな手続きではありません。Enumerating through a collection is intrinsically not a thread safe procedure. コレクションの同期がとられている場合でも、別のスレッドによってそのコレクションを変更できるため、変更の結果として列挙子は例外をスローします。Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. 列挙処理を確実にスレッド セーフに行うには、列挙中にコレクションをロックするか、他のスレッドによって行われた変更によってスローされる例外をキャッチします。To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

こちらもご覧ください