NameObjectCollectionBaseとは? わかりやすく解説

NameObjectCollectionBase クラス

関連付けられた String キーおよび Object 値のコレクションabstract 基本クラス提供します。これらのキーおよび値には、キーまたはインデックスいずれか使用してアクセスできます

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

<SerializableAttribute> _
Public MustInherit Class
 NameObjectCollectionBase
    Implements ICollection, IEnumerable, ISerializable, IDeserializationCallback
Dim instance As NameObjectCollectionBase
[SerializableAttribute] 
public abstract class NameObjectCollectionBase
 : ICollection, IEnumerable, ISerializable, 
    IDeserializationCallback
[SerializableAttribute] 
public ref class NameObjectCollectionBase abstract
 : ICollection, IEnumerable, ISerializable, 
    IDeserializationCallback
/** @attribute SerializableAttribute() */ 
public abstract class NameObjectCollectionBase
 implements ICollection, IEnumerable, 
    ISerializable, IDeserializationCallback
SerializableAttribute 
public abstract class NameObjectCollectionBase
 implements ICollection, IEnumerable, 
    ISerializable, IDeserializationCallback
解説解説

このクラスの基になる構造体ハッシュ テーブルです。

各要素キーと値のペアです。

NameObjectCollectionBase容量は、NameObjectCollectionBase保持できる要素数になりますNameObjectCollectionBase既定初期量はゼロです。NameObjectCollectionBase要素追加すると、必要に応じて、再割り当てを行うことによって容量自動的に増加します。

ハッシュ コード プロバイダは、キー対すハッシュ コードNameObjectCollectionBase インスタンス提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

比較演算子2 つキー等しかどうか判断します既定比較演算子は CaseInsensitiveComparer です。

.NET Framework Version 1.0場合、このクラスはカルチャに依存した文字列比較使用します。ただし、.NET Framework Version 1.1 以降場合、このクラスは文字列を比較するときに CultureInfo.InvariantCulture を使用します。カルチャが比較並べ替え与え影響詳細については、「固有カルチャのデータ比較並べ替え固有カルチャのデータ比較並べ替え」および「カルチャを認識しい文字操作実行」を参照してください

キーまたは値として null 参照 (Visual Basic では Nothing) を使用できます

注意に関するメモ注意

BaseGet メソッドでは、指定したキーが見つからないために返される null 参照 (Visual Basic では Nothing) と、キー関連付けられている値が null 参照 (Visual Basic では Nothing) であるために返される null 参照 (Visual Basic では Nothing) とが区別されません。

使用例使用例

NameObjectCollectionBase クラス実装および使用する方法については、次のコード例参照してください

Imports System
Imports System.Collections
Imports System.Collections.Specialized

Public Class MyCollection
   Inherits NameObjectCollectionBase

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

   ' 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 'New

   ' 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 'Add

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

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

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

End Class 'MyCollection


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 'Main

   ' 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 'PrintKeysAndValues

   ' 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 'PrintKeysAndValues2

End Class 'SamplesNameObjectCollectionBase


'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):

*/
#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):

*/
import System.* ;
import System.Collections.* ;
import System.Collections.Specialized.* ;

public class MyCollection extends NameObjectCollectionBase
{
    private DictionaryEntry _de =  new DictionaryEntry();

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

    // Adds elements from an IDictionary into the new collection.
    public MyCollection(IDictionary d, boolean bReadOnly) 
    {
        IDictionaryEnumerator objEnum = d.GetEnumerator();

        while (objEnum.MoveNext()) {        
            DictionaryEntry de = (DictionaryEntry)objEnum.get_Current();
            this.BaseAdd(((String)(de.get_Key())), de.get_Value());
        } 

        this.set_IsReadOnly(bReadOnly);        
    } //MyCollection

    // Gets a key-and-value pair (DictionaryEntry) using an index.
    /** @property 
     */
    public DictionaryEntry get_Item(int index)
    {
        _de.set_Key(this.BaseGetKey(index));
        _de.set_Value(this.BaseGet(index));
        return _de ;
    } //get_Item

    // Gets or sets the value associated with the specified key.
    /** @property 
     */
    public Object get_Item(String key)
    {
        return this.BaseGet(key) ;
    } //get_Item

    /** @property 
     */
    public void set_Item(String key, Object
 value)
    {
        this.BaseSet(key, value);
    } //set_Item

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

    // Gets an Object array that contains all the values in the collection.
    /** @property 
     */
    public Array get_AllValues()
    {
        return this.BaseGetAllValues() ;
    } //get_AllValues

    // Gets a String array that contains all the values in the collection.
    /** @property 
     */
    public String[] get_AllStringValues()
    {
        return((String[])(this.BaseGetAllValues(Type.GetType("String"))))
 ;
    } //get_AllStringValues

    // Gets a value indicating if the collection contains keys that
 are not null
    /** @property
     */
    public Boolean get_HasKeys()
    {
        return new Boolean(this.BaseHasKeys())
 ;
    } //get_HasKeys


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

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

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

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

public class SamplesNameObjectCollectionBase
 
{
    public static void main(String[]
 args)
    {
        // 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.set_Item( "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);
    } //main

    // Prints the indexes, keys, and values.
    public static void PrintKeysAndValues(MyCollection
 myCol)
    {

        for (int i=0; i < myCol.get_Count();
 i++) {        
            Console.WriteLine("[{0}] : {1}, {2}",System.Convert.ToString(i)
,
                myCol.get_Item(i).get_Key(), myCol.get_Item(i).get_Value());
        } 
    } //PrintKeysAndValues

    // Prints the keys and values using AllKeys.
    public static void PrintKeysAndValues2(MyCollection
 myCol)
    {
        String str = new String();

        for (int iCtr = 0; iCtr < myCol.get_Count();
 iCtr++) {        
            str = myCol.get_AllKeys()[iCtr];
            Console.WriteLine("{0} , {1}", str, 
                (myCol.get_Item(str)).ToString());
        } 
    } //PrintKeysAndValues2
} //SamplesNameObjectCollectionBase

/*
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(String[] args)
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):

*/
継承階層継承階層
System.Object
  System.Collections.Specialized.NameObjectCollectionBase
     派生クラス
スレッド セーフスレッド セーフ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
Hashtable クラス
NameValueCollection
String クラス
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ ()

NameObjectCollectionBase クラス新しい空のインスタンス初期化します。

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

Dim instance As New NameObjectCollectionBase
protected NameObjectCollectionBase ()
protected:
NameObjectCollectionBase ()
protected NameObjectCollectionBase ()
protected function NameObjectCollectionBase
 ()
解説解説

NameObjectCollectionBase容量は、NameObjectCollectionBase保持できる要素数になりますNameObjectCollectionBase要素追加すると、必要に応じて内部配列の再割り当てによって容量自動的に増加します。

コレクションサイズ推定できる場合は、初期量を指定すると、NameObjectCollectionBase要素追加するときに、サイズ変更操作何度も実行する必要がなくなります

ハッシュ コード プロバイダは、キー対すハッシュ コードNameObjectCollectionBase インスタンス提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

比較演算子2 つキー等しかどうか判断します既定比較演算子は CaseInsensitiveComparer です。

このコンストラクタは O(1) 操作です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
CaseInsensitiveHashCodeProvider クラス
CaseInsensitiveComparer クラス
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ (SerializationInfo, StreamingContext)

シリアル化でき、指定した System.Runtime.Serialization.SerializationInfoSystem.Runtime.Serialization.StreamingContext使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

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

Protected Sub New ( _
    info As SerializationInfo, _
    context As StreamingContext _
)
Dim info As SerializationInfo
Dim context As StreamingContext

Dim instance As New NameObjectCollectionBase(info,
 context)
protected NameObjectCollectionBase (
    SerializationInfo info,
    StreamingContext context
)
protected:
NameObjectCollectionBase (
    SerializationInfo^ info, 
    StreamingContext context
)
protected NameObjectCollectionBase (
    SerializationInfo info, 
    StreamingContext context
)
protected function NameObjectCollectionBase
 (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

新しい NameObjectCollectionBase インスタンスシリアル化するために必要な情報格納する System.Runtime.Serialization.SerializationInfo オブジェクト

context

新しNameObjectCollectionBase インスタンス関連付けられているシリアル化ストリームソースおよびデスティネーション格納する System.Runtime.Serialization.StreamingContext オブジェクト

解説解説

このコンストラクタは O(1) 操作です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
System.Runtime.Serialization.ISerializable
System.Runtime.Serialization.SerializationInfo
System.Runtime.Serialization.StreamingContext
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ (Int32)

空で、指定した初期量を備え既定ハッシュ コード プロバイダ既定比較演算子使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

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

Dim capacity As Integer

Dim instance As New NameObjectCollectionBase(capacity)
protected NameObjectCollectionBase (
    int capacity
)
protected:
NameObjectCollectionBase (
    int capacity
)
protected NameObjectCollectionBase (
    int capacity
)
protected function NameObjectCollectionBase
 (
    capacity : int
)

パラメータ

capacity

NameObjectCollectionBase が初期状態格納できるエントリの概数

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説

NameObjectCollectionBase容量は、NameObjectCollectionBase保持できる要素数になりますNameObjectCollectionBase要素追加すると、必要に応じて内部配列の再割り当てによって容量自動的に増加します。

コレクションサイズ推定できる場合は、初期量を指定すると、NameObjectCollectionBase要素追加するときに、サイズ変更操作何度も実行する必要がなくなります

ハッシュ コード プロバイダは、キー対すハッシュ コードNameObjectCollectionBase インスタンス提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

比較演算子2 つキー等しかどうか判断します既定比較演算子は CaseInsensitiveComparer です。

このコンストラクタは O(n) 操作です (ncapacity)。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
CaseInsensitiveHashCodeProvider クラス
CaseInsensitiveComparer クラス
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ (IEqualityComparer)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、既定初期量を備え指定した IEqualityComparer オブジェクト使用する、NameObjectCollectionBase クラス新しインスタンス初期化します。

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

Protected Sub New ( _
    equalityComparer As IEqualityComparer _
)
Dim equalityComparer As IEqualityComparer

Dim instance As New NameObjectCollectionBase(equalityComparer)
protected NameObjectCollectionBase (
    IEqualityComparer equalityComparer
)
protected:
NameObjectCollectionBase (
    IEqualityComparer^ equalityComparer
)
protected NameObjectCollectionBase (
    IEqualityComparer equalityComparer
)
protected function NameObjectCollectionBase
 (
    equalityComparer : IEqualityComparer
)

パラメータ

equalityComparer

2 つキー等しかどうか判断しコレクション内のキーハッシュ コード生成するために使用する IEqualityComparer オブジェクト

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
IEqualityComparer インターフェイス
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ (Int32, IEqualityComparer)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、指定した初期量を備え指定した IEqualityComparer オブジェクト使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

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

Protected Sub New ( _
    capacity As Integer, _
    equalityComparer As IEqualityComparer _
)
Dim capacity As Integer
Dim equalityComparer As IEqualityComparer

Dim instance As New NameObjectCollectionBase(capacity,
 equalityComparer)
protected NameObjectCollectionBase (
    int capacity,
    IEqualityComparer equalityComparer
)
protected:
NameObjectCollectionBase (
    int capacity, 
    IEqualityComparer^ equalityComparer
)
protected NameObjectCollectionBase (
    int capacity, 
    IEqualityComparer equalityComparer
)
protected function NameObjectCollectionBase
 (
    capacity : int, 
    equalityComparer : IEqualityComparer
)

パラメータ

capacity

NameObjectCollectionBase オブジェクト初期状態格納できるエントリの概数

equalityComparer

2 つキー等しかどうか判断しコレクション内のキーハッシュ コード生成するために使用する IEqualityComparer オブジェクト

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
IEqualityComparer インターフェイス
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ

NameObjectCollectionBase クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
NameObjectCollectionBase () NameObjectCollectionBase クラス新しい空のインスタンス初期化します。

.NET Compact Framework によってサポートされています。

NameObjectCollectionBase (IEqualityComparer) 空で、既定初期量を備え指定した IEqualityComparer オブジェクト使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

NameObjectCollectionBase (Int32) 空で、指定した初期量を備え既定ハッシュ コード プロバイダ既定比較演算子使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

NameObjectCollectionBase (IHashCodeProvider, IComparer) 空で、既定初期量を備え指定したハッシュ コード プロバイダ比較演算子使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

NameObjectCollectionBase (Int32, IEqualityComparer) 空で、指定した初期量を備え指定した IEqualityComparer オブジェクト使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

NameObjectCollectionBase (SerializationInfo, StreamingContext) シリアル化でき、指定した System.Runtime.Serialization.SerializationInfo と System.Runtime.Serialization.StreamingContext を使用するNameObjectCollectionBase クラス新しインスタンス初期化します。
NameObjectCollectionBase (Int32, IHashCodeProvider, IComparer) 空で、指定した初期量を備え指定したハッシュ コード プロバイダ比較演算子使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

参照参照

関連項目

NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
CaseInsensitiveHashCodeProvider クラス
CaseInsensitiveComparer クラス

その他の技術情報

カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ (IHashCodeProvider, IComparer)

メモ : このコンストラクタは、互換性のために残されています。

空で、既定初期量を備え指定したハッシュ コード プロバイダ比較演算子使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

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

<ObsoleteAttribute("Please use NameObjectCollectionBase(IEqualityComparer)
 instead.")> _
Protected Sub New ( _
    hashProvider As IHashCodeProvider, _
    comparer As IComparer _
)
Dim hashProvider As IHashCodeProvider
Dim comparer As IComparer

Dim instance As New NameObjectCollectionBase(hashProvider,
 comparer)
[ObsoleteAttribute("Please use NameObjectCollectionBase(IEqualityComparer) instead.")]
 
protected NameObjectCollectionBase (
    IHashCodeProvider hashProvider,
    IComparer comparer
)
[ObsoleteAttribute(L"Please use NameObjectCollectionBase(IEqualityComparer)
 instead.")] 
protected:
NameObjectCollectionBase (
    IHashCodeProvider^ hashProvider, 
    IComparer^ comparer
)
/** @attribute ObsoleteAttribute("Please use NameObjectCollectionBase(IEqualityComparer)
 instead.") */ 
protected NameObjectCollectionBase (
    IHashCodeProvider hashProvider, 
    IComparer comparer
)
ObsoleteAttribute("Please use NameObjectCollectionBase(IEqualityComparer) instead.")
 
protected function NameObjectCollectionBase
 (
    hashProvider : IHashCodeProvider, 
    comparer : IComparer
)

パラメータ

hashProvider

NameObjectCollectionBase インスタンス内のすべてのキーハッシュ コード提供する IHashCodeProvider。

comparer

2 つキー等しかどうか判断するために使用する IComparer。

解説解説

NameObjectCollectionBase容量は、NameObjectCollectionBase保持できる要素数になりますNameObjectCollectionBase要素追加すると、必要に応じて内部配列の再割り当てによって容量自動的に増加します。

コレクションサイズ推定できる場合は、初期量を指定すると、NameObjectCollectionBase要素追加するときに、サイズ変更操作何度も実行する必要がなくなります

ハッシュ コード プロバイダは、キー対すハッシュ コードNameObjectCollectionBase インスタンス提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

比較演算子2 つキー等しかどうか判断します既定比較演算子は CaseInsensitiveComparer です。

このコンストラクタは O(1) 操作です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
IHashCodeProvider インターフェイス
IComparer インターフェイス
CaseInsensitiveHashCodeProvider クラス
CaseInsensitiveComparer クラス
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase コンストラクタ (Int32, IHashCodeProvider, IComparer)

メモ : このコンストラクタは、互換性のために残されています。

空で、指定した初期量を備え指定したハッシュ コード プロバイダ比較演算子使用するNameObjectCollectionBase クラス新しインスタンス初期化します。

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

<ObsoleteAttribute("Please use NameObjectCollectionBase(Int32,
 IEqualityComparer) instead.")> _
Protected Sub New ( _
    capacity As Integer, _
    hashProvider As IHashCodeProvider, _
    comparer As IComparer _
)
Dim capacity As Integer
Dim hashProvider As IHashCodeProvider
Dim comparer As IComparer

Dim instance As New NameObjectCollectionBase(capacity,
 hashProvider, comparer)
[ObsoleteAttribute("Please use NameObjectCollectionBase(Int32, IEqualityComparer)
 instead.")] 
protected NameObjectCollectionBase (
    int capacity,
    IHashCodeProvider hashProvider,
    IComparer comparer
)
[ObsoleteAttribute(L"Please use NameObjectCollectionBase(Int32, IEqualityComparer)
 instead.")] 
protected:
NameObjectCollectionBase (
    int capacity, 
    IHashCodeProvider^ hashProvider, 
    IComparer^ comparer
)
/** @attribute ObsoleteAttribute("Please use NameObjectCollectionBase(Int32,
 IEqualityComparer) instead.") */ 
protected NameObjectCollectionBase (
    int capacity, 
    IHashCodeProvider hashProvider, 
    IComparer comparer
)
ObsoleteAttribute("Please use NameObjectCollectionBase(Int32, IEqualityComparer)
 instead.") 
protected function NameObjectCollectionBase
 (
    capacity : int, 
    hashProvider : IHashCodeProvider, 
    comparer : IComparer
)

パラメータ

capacity

NameObjectCollectionBase が初期状態格納できるエントリの概数

hashProvider

NameObjectCollectionBase インスタンス内のすべてのキーハッシュ コード提供する IHashCodeProvider。

comparer

2 つキー等しかどうか判断するために使用する IComparer。

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説

NameObjectCollectionBase容量は、NameObjectCollectionBase保持できる要素数になりますNameObjectCollectionBase要素追加すると、必要に応じて内部配列の再割り当てによって容量自動的に増加します。

コレクションサイズ推定できる場合は、初期量を指定すると、NameObjectCollectionBase要素追加するときに、サイズ変更操作何度も実行する必要がなくなります

ハッシュ コード プロバイダは、キー対すハッシュ コードNameObjectCollectionBase インスタンス提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

比較演算子2 つキー等しかどうか判断します既定比較演算子は CaseInsensitiveComparer です。

このコンストラクタは O(n) 操作です (ncapacity)。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameObjectCollectionBase クラス
NameObjectCollectionBase メンバ
System.Collections.Specialized 名前空間
IHashCodeProvider インターフェイス
CaseInsensitiveHashCodeProvider クラス
IComparer インターフェイス
CaseInsensitiveComparer クラス
その他の技術情報
カルチャを認識しい文字操作実行

NameObjectCollectionBase プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Keys NameObjectCollectionBase インスタンス内のすべてのキー格納する NameObjectCollectionBase.KeysCollection インスタンス取得します
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ IsReadOnly NameObjectCollectionBase インスタンス読み取り専用かどうかを示す値を取得または設定します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot NameObjectCollectionBase オブジェクトへのアクセス同期するために使用できるオブジェクト取得します
参照参照

関連項目

NameObjectCollectionBase クラス
System.Collections.Specialized 名前空間
Hashtable クラス
NameValueCollection
String クラス

その他の技術情報

カルチャを認識しい文字操作実行

NameObjectCollectionBase メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド BaseAdd 指定したキーと値を持つエントリを NameObjectCollectionBase インスタンス追加します
プロテクト メソッド BaseClear NameObjectCollectionBase インスタンスかすべてのエントリを削除します
プロテクト メソッド BaseGet オーバーロードされますNameObjectCollectionBase インスタンスから、指定したエントリの値を取得します
プロテクト メソッド BaseGetAllKeys NameObjectCollectionBase インスタンス内のすべてのキー格納する String 配列返します
プロテクト メソッド BaseGetAllValues オーバーロードされますNameObjectCollectionBase インスタンス内のすべての値を格納する配列返します
プロテクト メソッド BaseGetKey NameObjectCollectionBase インスタンス指定したインデックスにあるエントリのキー取得します
プロテクト メソッド BaseHasKeys NameObjectCollectionBase インスタンスが、キーnull 参照 (Visual Basic では Nothing) ではないエントリを格納しているかどうかを示す値を取得します
プロテクト メソッド BaseRemove 指定したキーを持つエントリを NameObjectCollectionBase インスタンスか削除します
プロテクト メソッド BaseRemoveAt NameObjectCollectionBase インスタンス指定したインデックスにあるエントリを削除します
プロテクト メソッド BaseSet オーバーロードされますNameObjectCollectionBase インスタンス内のエントリの値を設定します
プロテクト メソッド Finalize  Objectガベージ コレクションにより収集される前に、その Objectリソース解放しその他のクリーンアップ操作実行できるようにします。 ( Object から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object簡易コピー作成します。 ( Object から継承されます。)
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo NameObjectCollectionBase 全体互換性のある 1 次元Arrayコピーしますコピー操作は、コピー先の配列指定したインデックスから始まります
参照参照

関連項目

NameObjectCollectionBase クラス
System.Collections.Specialized 名前空間
Hashtable クラス
NameValueCollection
String クラス

その他の技術情報

カルチャを認識しい文字操作実行

NameObjectCollectionBase メンバ

関連付けられた String キーおよび Object 値のコレクションabstract 基本クラス提供します。これらのキーおよび値には、キーまたはインデックスいずれか使用してアクセスできます

NameObjectCollectionBase データ型公開されるメンバを以下の表に示します


プロテクト コンストラクタプロテクト コンストラクタ
  名前 説明
プロテクト メソッド NameObjectCollectionBase オーバーロードされますNameObjectCollectionBase クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Keys NameObjectCollectionBase インスタンス内のすべてのキー格納する NameObjectCollectionBase.KeysCollection インスタンス取得します
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ IsReadOnly NameObjectCollectionBase インスタンス読み取り専用かどうかを示す値を取得または設定します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド BaseAdd 指定したキーと値を持つエントリを NameObjectCollectionBase インスタンス追加します
プロテクト メソッド BaseClear NameObjectCollectionBase インスタンスかすべてのエントリを削除します
プロテクト メソッド BaseGet オーバーロードされますNameObjectCollectionBase インスタンスから、指定したエントリの値を取得します
プロテクト メソッド BaseGetAllKeys NameObjectCollectionBase インスタンス内のすべてのキー格納する String 配列返します
プロテクト メソッド BaseGetAllValues オーバーロードされますNameObjectCollectionBase インスタンス内のすべての値を格納する配列返します
プロテクト メソッド BaseGetKey NameObjectCollectionBase インスタンス指定したインデックスにあるエントリのキー取得します
プロテクト メソッド BaseHasKeys NameObjectCollectionBase インスタンスが、キーnull 参照 (Visual Basic では Nothing) ではないエントリを格納しているかどうかを示す値を取得します
プロテクト メソッド BaseRemove 指定したキーを持つエントリを NameObjectCollectionBase インスタンスか削除します
プロテクト メソッド BaseRemoveAt NameObjectCollectionBase インスタンス指定したインデックスにあるエントリを削除します
プロテクト メソッド BaseSet オーバーロードされますNameObjectCollectionBase インスタンス内のエントリの値を設定します
プロテクト メソッド Finalize  Objectガベージ コレクションにより収集される前に、その Objectリソース解放しその他のクリーンアップ操作実行できるようにします。 (Object から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object簡易コピー作成します。 (Object から継承されます。)
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo NameObjectCollectionBase 全体互換性のある 1 次元Arrayコピーしますコピー操作は、コピー先の配列指定したインデックスから始まります
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot NameObjectCollectionBase オブジェクトへのアクセス同期するために使用できるオブジェクト取得します
参照参照

関連項目

NameObjectCollectionBase クラス
System.Collections.Specialized 名前空間
Hashtable クラス
NameValueCollection
String クラス

その他の技術情報

カルチャを認識しい文字操作実行



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

辞書ショートカット

すべての辞書の索引

「NameObjectCollectionBase」の関連用語

NameObjectCollectionBaseのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS