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

NameValueCollection クラス

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

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

<SerializableAttribute> _
Public Class NameValueCollection
    Inherits NameObjectCollectionBase
Dim instance As NameValueCollection
[SerializableAttribute] 
public class NameValueCollection : NameObjectCollectionBase
[SerializableAttribute] 
public ref class NameValueCollection : public
 NameObjectCollectionBase
/** @attribute SerializableAttribute() */ 
public class NameValueCollection extends NameObjectCollectionBase
SerializableAttribute 
public class NameValueCollection extends
 NameObjectCollectionBase
解説解説

このコレクションNameObjectCollectionBase クラス基づいてます。ただし、NameObjectCollectionBase とは異なり、このクラスには 1 つキー複数文字列値を格納します

このクラスは、ヘッダークエリ文字列、およびフォーム データ使用できます

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

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

ハッシュ コード プロバイダは、NameValueCollection 内のキーハッシュ コード提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

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

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

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

注意に関するメモ注意

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

使用例使用例
' The following code example demonstrates several of the properties
 and methods of ListDictionary.

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


Public Class SamplesNameValueCollection

    Public Shared Sub Main()

        ' Creates and initializes a new NameValueCollection.
        Dim myCol As New
 NameValueCollection()
        myCol.Add("red", "rojo")
        myCol.Add("green", "verde")
        myCol.Add("blue", "azul")
        myCol.Add("red", "rouge")

        ' Displays the values in the NameValueCollection in two different
 ways.
        Console.WriteLine("Displays the elements using the AllKeys
 property and the Item (indexer) property:")
        PrintKeysAndValues(myCol)
        Console.WriteLine("Displays the elements using GetKey
 and Get:")
        PrintKeysAndValues2(myCol)

        ' Gets a value either by index or by key.
        Console.WriteLine("Index 1 contains the value {0}.",
 myCol(1))
        Console.WriteLine("Key ""red""
 has the value {0}.", myCol("red"))
        Console.WriteLine()

        ' Copies the values to a string array and displays the string
 array.
        Dim myStrArr(myCol.Count) As String
        myCol.CopyTo(myStrArr, 0)
        Console.WriteLine("The string array contains:")
        Dim s As String
        For Each s In myStrArr
            Console.WriteLine("   {0}", s)
        Next s
        Console.WriteLine()

        ' Searches for a key and deletes it.
        myCol.Remove("green")
        Console.WriteLine("The collection contains the following
 elements after removing ""green"":")
        PrintKeysAndValues(myCol)

        ' Clears the entire collection.
        myCol.Clear()
        Console.WriteLine("The collection contains the following
 elements after it is cleared:")
        PrintKeysAndValues(myCol)

    End Sub 'Main

    Public Shared Sub PrintKeysAndValues(myCol
 As NameValueCollection)
        Dim myEnumerator As IEnumerator = myCol.GetEnumerator()
        Console.WriteLine("   KEY        VALUE")
        Dim s As String
        For Each s In  myCol.AllKeys
            Console.WriteLine("   {0,-10} {1}", s,
 myCol(s))
        Next s
        Console.WriteLine()
    End Sub 'PrintKeysAndValues

    Public Shared Sub PrintKeysAndValues2(myCol
 As NameValueCollection)
        Console.WriteLine("   [INDEX] KEY        VALUE")
        Dim i As Integer
        For i = 0 To myCol.Count - 1
            Console.WriteLine("   [{0}]     {1,-10} {2}",
 i, myCol.GetKey(i), myCol.Get(i))
        Next i
        Console.WriteLine()
    End Sub 'PrintKeysAndValues2

End Class 'SamplesNameValueCollection
 


'This code produces the following output.
'
'Displays the elements using the AllKeys property and the Item (indexer)
 property:
'   KEY        VALUE
'   red        rojo,rouge
'   green      verde
'   blue       azul
'
'Displays the elements using GetKey and Get:
'   [INDEX] KEY        VALUE
'   [0]     red        rojo,rouge
'   [1]     green      verde
'   [2]     blue       azul
'
'Index 1 contains the value verde.
'Key "red" has the value rojo,rouge.
'
'The string array contains:
'   red
'   green
'   blue
'
'
'The collection contains the following elements after removing "green":
'   KEY        VALUE
'   red        rojo,rouge
'   blue       azul
'
'The collection contains the following elements after it is cleared:
'   KEY        VALUE
'
'
using System;
using System.Collections;
using System.Collections.Specialized;

public class SamplesNameValueCollection  {

   public static void Main()
  {

      // Creates and initializes a new NameValueCollection.
      NameValueCollection myCol = new NameValueCollection();
      myCol.Add( "red", "rojo" );
      myCol.Add( "green", "verde" );
      myCol.Add( "blue", "azul" );
      myCol.Add( "red", "rouge" );

      // Displays the values in the NameValueCollection in two different
 ways.
      Console.WriteLine( "Displays the elements using the
 AllKeys property and the Item (indexer) property:" );
      PrintKeysAndValues( myCol );
      Console.WriteLine( "Displays the elements using GetKey
 and Get:" );
      PrintKeysAndValues2( myCol );

      // Gets a value either by index or by key.
      Console.WriteLine( "Index 1 contains the value {0}.", myCol[1] );
      Console.WriteLine( "Key \"red\" has the value {0}.", myCol["red"]
 );
      Console.WriteLine();

      // Copies the values to a string array and displays the string
 array.
      String[] myStrArr = new String[myCol.Count];
      myCol.CopyTo( myStrArr, 0 );
      Console.WriteLine( "The string array contains:"
 );
      foreach ( String s in myStrArr )
         Console.WriteLine( "   {0}", s );
      Console.WriteLine();

      // Searches for a key and deletes it.
      myCol.Remove( "green" );
      Console.WriteLine( "The collection contains the following elements after
 removing \"green\":" );
      PrintKeysAndValues( myCol );

      // Clears the entire collection.
      myCol.Clear();
      Console.WriteLine( "The collection contains the following elements after
 it is cleared:" );
      PrintKeysAndValues( myCol );

   }

   public static void PrintKeysAndValues(
 NameValueCollection myCol )  {
      IEnumerator myEnumerator = myCol.GetEnumerator();
      Console.WriteLine( "   KEY        VALUE" );
      foreach ( String s in myCol.AllKeys )
         Console.WriteLine( "   {0,-10} {1}", s, myCol[s] );
      Console.WriteLine();
   }

   public static void PrintKeysAndValues2(
 NameValueCollection myCol )  {
      Console.WriteLine( "   [INDEX] KEY        VALUE" );
      for ( int i = 0; i < myCol.Count;
 i++ )
         Console.WriteLine( "   [{0}]     {1,-10} {2}", i, myCol.GetKey(i),
 myCol.Get(i) );
      Console.WriteLine();
   }


}

/*

This code produces the following output.

Displays the elements using the AllKeys property and the Item
 (indexer) property:
   KEY        VALUE
   red        rojo,rouge
   green      verde
   blue       azul

Displays the elements using GetKey and Get:
   [INDEX] KEY        VALUE
   [0]     red        rojo,rouge
   [1]     green      verde
   [2]     blue       azul

Index 1 contains the value verde.
Key "red" has the value rojo,rouge.

The string array contains:
   rojo,rouge
   verde
   azul

The collection contains the following elements after removing "green":
   KEY        VALUE
   red        rojo,rouge
   blue       azul

The collection contains the following elements after it is cleared:
   KEY        VALUE


*/
#using <System.dll>

using namespace System;
using namespace System::Collections;
using namespace System::Collections::Specialized;

void PrintKeysAndValues( NameValueCollection^ myCol );
void PrintKeysAndValues2( NameValueCollection^ myCol );

int main()
{
   // Creates and initializes a new NameValueCollection.
   NameValueCollection^ myCol = gcnew NameValueCollection;
   myCol->Add( "red", "rojo" );
   myCol->Add( "green", "verde" );
   myCol->Add( "blue", "azul" );
   myCol->Add( "red", "rouge" );

   // Displays the values in the NameValueCollection in two different
 ways.
   Console::WriteLine( "Displays the elements using the AllKeys property and the Item
 (indexer) property:" );
   PrintKeysAndValues( myCol );
   Console::WriteLine( "Displays the elements using GetKey
 and Get:" );
   PrintKeysAndValues2( myCol );

   // Gets a value either by index or by key.
   Console::WriteLine( "Index 1 contains the value {0}.", myCol[ 1 ] );
   Console::WriteLine( "Key \"red\" has the value {0}.", myCol[
 "red" ] );
   Console::WriteLine();

   // Copies the values to a string array and displays the string array.
   array<String^>^myStrArr = gcnew array<String^>(myCol->Count);
   myCol->CopyTo( myStrArr, 0 );
   Console::WriteLine( "The string array contains:"
 );
   for each ( String^ s in myStrArr )
      Console::WriteLine( "   {0}", s );
   Console::WriteLine();

   // Searches for a key and deletes it.
   myCol->Remove( "green" );
   Console::WriteLine( "The collection contains the following elements after
 removing \"green\":" );
   PrintKeysAndValues( myCol );

   // Clears the entire collection.
   myCol->Clear();
   Console::WriteLine( "The collection contains the following elements after
 it is cleared:" );
   PrintKeysAndValues( myCol );
}

void PrintKeysAndValues( NameValueCollection^ myCol )
{
   Console::WriteLine( "   KEY        VALUE" );
   for each ( String^ s in myCol->AllKeys
 )
      Console::WriteLine( "   {0,-10} {1}", s, myCol[s] );
   Console::WriteLine();
}

void PrintKeysAndValues2( NameValueCollection^ myCol )
{
   Console::WriteLine( "   [INDEX] KEY        VALUE" );
   for ( int i = 0; i < myCol->Count;
 i++ )
      Console::WriteLine( "   [{0}]     {1,-10} {2}", i, myCol->GetKey(
 i ), myCol->Get( i ) );
   Console::WriteLine();
}

/*

This code produces the following output.

Displays the elements using the AllKeys property and the Item
 (indexer) property:
   KEY        VALUE
   red        rojo,rouge
   green      verde
   blue       azul

Displays the elements using GetKey and Get:
   [INDEX] KEY        VALUE
   [0]     red        rojo,rouge
   [1]     green      verde
   [2]     blue       azul

Index 1 contains the value verde.
Key "red" has the value rojo,rouge.

The string array contains:
   rojo,rouge
   verde
   azul

The collection contains the following elements after removing "green":
   KEY        VALUE
   red        rojo,rouge
   blue       azul

The collection contains the following elements after it is cleared:
   KEY        VALUE


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

public class SamplesNameValueCollection
{
    public static void main(String[]
 args)
    {
        // Creates and initializes a new NameValueCollection.
        NameValueCollection myCol = new NameValueCollection();
        myCol.Add("red", "rojo");
        myCol.Add("green", "verde");
        myCol.Add("blue", "azul");
        myCol.Add("red", "rouge");
        // Displays the values in the NameValueCollection in two different
 ways.
        Console.WriteLine("Displays the elements using the
 AllKeys property" 
            + " and the Item (indexer) property:");
        PrintKeysAndValues(myCol);
        Console.WriteLine("Displays the elements using GetKey
 and Get:");
        PrintKeysAndValues2(myCol);
        // Gets a value either by index or by key.
        Console.WriteLine("Index 1 contains the value {0}.", myCol.get_Item(1));
        Console.WriteLine("Key \"red\" has the value {0}.",
            myCol.get_Item("red"));
        Console.WriteLine();
        // Copies the values to a string array and displays the string
 array.
        String myStrArr[] = new String[myCol.get_Count()];
        myCol.CopyTo(myStrArr, 0);
        Console.WriteLine("The string array contains:");
        for (int iCtr = 0; iCtr < myStrArr.get_Length();
 iCtr++) {
            String s = myStrArr[iCtr];
            Console.WriteLine("   {0}", s);
        }
        Console.WriteLine();
        // Searches for a key and deletes it.
        myCol.Remove("green");
        Console.WriteLine("The collection contains the following elements "
 
            + "after removing \"green\":");
        PrintKeysAndValues(myCol);
        // Clears the entire collection.
        myCol.Clear();
        Console.WriteLine("The collection contains the following elements "
 
            + "after it is cleared:");
        PrintKeysAndValues(myCol);
    } //main

    public static void PrintKeysAndValues(NameValueCollection
 myCol)
    {
        IEnumerator myEnumerator = myCol.GetEnumerator();
        Console.WriteLine("   KEY        VALUE");
        for (int iCtr = 0; iCtr < myCol.get_Count();
 iCtr++) {
            String s = myCol.get_AllKeys()[iCtr];
            Console.WriteLine("   {0,-10} {1}", s, myCol.get_Item(s));
        }
        Console.WriteLine();
    } //PrintKeysAndValues

    public static void PrintKeysAndValues2(NameValueCollection
 myCol)
    {
        Console.WriteLine("   [INDEX] KEY        VALUE");
        for (int i = 0; i < myCol.get_Count();
 i++) {
            Console.WriteLine("   [{0}]     {1,-10} {2}",
                System.Convert.ToString(i), System.Convert.ToString(
                myCol.GetKey(i)), System.Convert.ToString(myCol.Get(i)));
        }
        Console.WriteLine();
    } //PrintKeysAndValues2
} //SamplesNameValueCollection 

/*
    This code produces the following output.
    Displays the elements using the AllKeys property and the Item
 
    (indexer) property:
    KEY        VALUE
    red        rojo,rouge
    green      verde
    blue       azul

    Displays the elements using GetKey and Get:
    [INDEX] KEY        VALUE
    [0]     red        rojo,rouge
    [1]     green      verde
    [2]     blue       azul
     
    Index 1 contains the value verde.
    Key "red" has the value rojo,rouge.
    
    The string array contains:
    rojo,rouge
    verde
    azul

    The collection contains the following elements after removing "green":
    KEY        VALUE
    red        rojo,rouge
    blue       azul

    The collection contains the following elements after it is cleared:
    KEY        VALUE       
*/
継承階層継承階層
System.Object
   System.Collections.Specialized.NameObjectCollectionBase
    System.Collections.Specialized.NameValueCollection
       System.Net.WebHeaderCollection
       System.Web.HttpClientCertificate
スレッド セーフスレッド セーフ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
NameValueCollection メンバ
System.Collections.Specialized 名前空間
NameObjectCollectionBase クラス
その他の技術情報
カルチャを認識しい文字操作実行

NameValueCollection コンストラクタ ()

空で、既定初期量を備え大文字と小文字区別しない既定ハッシュ コード プロバイダ比較演算子使用する、NameValueCollection クラス新しインスタンス初期化します。

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

Dim instance As New NameValueCollection
public NameValueCollection ()
public:
NameValueCollection ()
public NameValueCollection ()
public function NameValueCollection ()
解説解説

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

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

ハッシュ コード プロバイダは、NameValueCollection 内のキーハッシュ コード提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

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

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

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

NameValueCollection コンストラクタ (Int32)

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

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

public NameValueCollection (
    int capacity
)
public:
NameValueCollection (
    int capacity
)
public NameValueCollection (
    int capacity
)
public function NameValueCollection (
    capacity : int
)

パラメータ

capacity

NameValueCollection に格納できるエントリ数の初期値

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説

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

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

ハッシュ コード プロバイダは、NameValueCollection 内のキーハッシュ コード提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

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

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

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

NameValueCollection コンストラクタ (NameValueCollection)

コピーされるエントリの数と同じ初期量を備えソース コレクションと同じハッシュ コード プロバイダおよび比較演算子使用する新しNameValueCollection に、指定した NameValueCollection からエントリをコピーします

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

Public Sub New ( _
    col As NameValueCollection _
)
Dim col As NameValueCollection

Dim instance As New NameValueCollection(col)
public NameValueCollection (
    NameValueCollection col
)
public:
NameValueCollection (
    NameValueCollection^ col
)
public NameValueCollection (
    NameValueCollection col
)
public function NameValueCollection (
    col : NameValueCollection
)

パラメータ

col

新しい NameValueCollection インスタンスコピーする NameValueCollection

例外例外
例外種類条件

ArgumentNullException

colnull 参照 (Visual Basic では Nothing) です。

解説解説

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

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

ハッシュ コード プロバイダは、NameValueCollection 内のキーハッシュ コード提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

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

新しNameValueCollection要素は、ソース NameValueCollection と同じ順序並べ替えられます。

このコンストラクタは O(n) 操作です。ここで、ncol 内の要素数です。

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

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

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

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

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

<ObsoleteAttribute("Please use NameValueCollection(Int32, IEqualityComparer)
 instead.")> _
Public 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 NameValueCollection(capacity,
 hashProvider, comparer)
[ObsoleteAttribute("Please use NameValueCollection(Int32, IEqualityComparer)
 instead.")] 
public NameValueCollection (
    int capacity,
    IHashCodeProvider hashProvider,
    IComparer comparer
)
[ObsoleteAttribute(L"Please use NameValueCollection(Int32, IEqualityComparer)
 instead.")] 
public:
NameValueCollection (
    int capacity, 
    IHashCodeProvider^ hashProvider, 
    IComparer^ comparer
)
/** @attribute ObsoleteAttribute("Please use NameValueCollection(Int32, IEqualityComparer)
 instead.") */ 
public NameValueCollection (
    int capacity, 
    IHashCodeProvider hashProvider, 
    IComparer comparer
)
ObsoleteAttribute("Please use NameValueCollection(Int32, IEqualityComparer)
 instead.") 
public function NameValueCollection (
    capacity : int, 
    hashProvider : IHashCodeProvider, 
    comparer : IComparer
)

パラメータ

capacity

NameValueCollection に格納できるエントリ数の初期値

hashProvider

NameValueCollection 内のすべてのキーハッシュ コード提供する IHashCodeProvider。

comparer

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

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説

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

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

ハッシュ コード プロバイダは、NameValueCollection 内のキーハッシュ コード提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

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

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

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

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

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

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

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

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

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

パラメータ

hashProvider

NameValueCollection 内のすべてのキーハッシュ コード提供する IHashCodeProvider。

comparer

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

解説解説

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

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

ハッシュ コード プロバイダは、NameValueCollection 内のキーハッシュ コード提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

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

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

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

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

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

名前空間: 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 NameValueCollection(info,
 context)
protected NameValueCollection (
    SerializationInfo info,
    StreamingContext context
)
protected:
NameValueCollection (
    SerializationInfo^ info, 
    StreamingContext context
)
protected NameValueCollection (
    SerializationInfo info, 
    StreamingContext context
)
protected function NameValueCollection (
    info : SerializationInfo, 
    context : StreamingContext
)

パラメータ

info

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

context

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

解説解説

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

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

NameValueCollection コンストラクタ (Int32, NameValueCollection)

指定した初期量またはコピーされるエントリの数と同じ初期量のうち値が大きい方の初期量を備え大文字と小文字区別しない既定ハッシュ コード プロバイダおよび比較演算子使用する新しNameValueCollection に、指定した NameValueCollection からエントリをコピーします

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

Public Sub New ( _
    capacity As Integer, _
    col As NameValueCollection _
)
Dim capacity As Integer
Dim col As NameValueCollection

Dim instance As New NameValueCollection(capacity,
 col)
public NameValueCollection (
    int capacity,
    NameValueCollection col
)
public:
NameValueCollection (
    int capacity, 
    NameValueCollection^ col
)
public NameValueCollection (
    int capacity, 
    NameValueCollection col
)
public function NameValueCollection (
    capacity : int, 
    col : NameValueCollection
)

パラメータ

capacity

NameValueCollection に格納できるエントリ数の初期値

col

新しNameValueCollection インスタンスコピーする NameValueCollection

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

ArgumentNullException

colnull 参照 (Visual Basic では Nothing) です。

解説解説

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

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

ハッシュ コード プロバイダは、NameValueCollection 内のキーハッシュ コード提供します既定ハッシュ コード プロバイダは CaseInsensitiveHashCodeProvider です。

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

このコンストラクタは O(n) 操作です。ここで、ncapacity です。col要素数が capacity超えている場合、このコンストラクタは O(n + m) 操作なります。ここで、ncapacity で、mcol要素数です。

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

NameValueCollection コンストラクタ (IEqualityComparer)

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

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

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

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

Dim instance As New NameValueCollection(equalityComparer)
public NameValueCollection (
    IEqualityComparer equalityComparer
)
public:
NameValueCollection (
    IEqualityComparer^ equalityComparer
)
public NameValueCollection (
    IEqualityComparer equalityComparer
)
public function NameValueCollection (
    equalityComparer : IEqualityComparer
)

パラメータ

equalityComparer

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

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

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

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

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

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

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

Dim instance As New NameValueCollection(capacity,
 equalityComparer)
public NameValueCollection (
    int capacity,
    IEqualityComparer equalityComparer
)
public:
NameValueCollection (
    int capacity, 
    IEqualityComparer^ equalityComparer
)
public NameValueCollection (
    int capacity, 
    IEqualityComparer equalityComparer
)
public function NameValueCollection (
    capacity : int, 
    equalityComparer : IEqualityComparer
)

パラメータ

capacity

NameValueCollection オブジェクト格納できるエントリ数の初期値

equalityComparer

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

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

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

NameValueCollection コンストラクタ

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

名前 説明
NameValueCollection () 空で、既定初期量を備え大文字と小文字区別しない既定ハッシュ コード プロバイダ比較演算子使用するNameValueCollection クラス新しインスタンス初期化します。

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

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

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

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

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

NameValueCollection (NameValueCollection) コピーされるエントリの数と同じ初期量を備えソース コレクションと同じハッシュ コード プロバイダおよび比較演算子使用する新しNameValueCollection に、指定した NameValueCollection からエントリをコピーします

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

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

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

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

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

NameValueCollection (Int32, NameValueCollection) 指定した初期量またはコピーされるエントリの数と同じ初期量のうち値が大きい方の初期量を備え大文字と小文字区別しない既定ハッシュ コード プロバイダおよび比較演算子使用する新しNameValueCollection に、指定した NameValueCollection からエントリをコピーします

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

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

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

参照参照

関連項目

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

その他の技術情報

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

NameValueCollection プロパティ


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

( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Count  NameObjectCollectionBase インスタンス格納されているキーと値のペアの数を取得します。 ( NameObjectCollectionBase から継承されます。)
パブリック プロパティ Item オーバーロードされますNameValueCollection指定したエントリを取得または設定します
パブリック プロパティ Keys  NameObjectCollectionBase インスタンス内のすべてのキー格納する NameObjectCollectionBase.KeysCollection インスタンス取得します。 ( NameObjectCollectionBase から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ IsReadOnly  NameObjectCollectionBase インスタンス読み取り専用かどうかを示す値を取得または設定します。 ( NameObjectCollectionBase から継承されます。)
参照参照

関連項目

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

その他の技術情報

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

NameValueCollection メソッド


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

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add オーバーロードされます現在の NameValueCollection にエントリを追加します
パブリック メソッド Clear キャッシュ保存され配列無効化し、NameValueCollection からすべてのエントリを削除します
パブリック メソッド CopyTo NameValueCollection 全体互換性のある 1 次元Arrayコピーしますコピー操作は、コピー先の配列指定したインデックスから始まります
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド Get オーバーロードされますNameValueCollection 内で指定したエントリの値をいくつか取得し1 つコンマ区切りリスト組み合わせます。
パブリック メソッド GetEnumerator  NameObjectCollectionBase を反復処理する列挙子を返します。 ( NameObjectCollectionBase から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetKey NameValueCollection指定したインデックスにあるキー取得します
パブリック メソッド GetObjectData  ISerializable インターフェイス実装し、NameObjectCollectionBase インスタンスシリアル化するために必要なデータ返します。 ( NameObjectCollectionBase から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド GetValues オーバーロードされますNameValueCollection 内の指定したエントリの値を取得します
パブリック メソッド HasKeys NameValueCollection が、null 参照 (Visual Basic では Nothing) ではないキー格納しているかどうかを示す値を取得します
パブリック メソッド OnDeserialization  ISerializable インターフェイス実装し、逆シリアル化完了したときに逆シリアル化イベント発生させます。 ( NameObjectCollectionBase から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Remove 指定したキーを持つエントリを NameObjectCollectionBase インスタンスか削除します
パブリック メソッド Set NameValueCollection 内のエントリの値を設定します
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド BaseAdd  指定したキーと値を持つエントリを NameObjectCollectionBase インスタンス追加します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseClear  NameObjectCollectionBase インスタンスかすべてのエントリを削除します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGet  オーバーロードされますNameObjectCollectionBase インスタンスから、指定したエントリの値を取得します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGetAllKeys  NameObjectCollectionBase インスタンス内のすべてのキー格納する String 配列返します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGetAllValues  オーバーロードされますNameObjectCollectionBase インスタンス内のすべての値を格納する配列返します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGetKey  NameObjectCollectionBase インスタンス指定したインデックスにあるエントリのキー取得します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseHasKeys  NameObjectCollectionBase インスタンスが、キーnull 参照 (Visual Basic では Nothing) ではないエントリを格納しているかどうかを示す値を取得します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseRemove  指定したキーを持つエントリを NameObjectCollectionBase インスタンスか削除します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseRemoveAt  NameObjectCollectionBase インスタンス指定したインデックスにあるエントリを削除します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseSet  オーバーロードされますNameObjectCollectionBase インスタンス内のエントリの値を設定します。 ( NameObjectCollectionBase から継承されます。)
プロテクト メソッド Finalize  Objectガベージ コレクションにより収集される前に、その Objectリソース解放しその他のクリーンアップ操作実行できるようにします。 ( Object から継承されます。)
プロテクト メソッド InvalidateCachedArrays コレクション内でキャッシュ保存され配列null 参照 (Visual Basic では Nothing) にリセットします。
プロテクト メソッド MemberwiseClone  現在の Object簡易コピー作成します。 ( Object から継承されます。)
参照参照

関連項目

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

その他の技術情報

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

NameValueCollection メンバ

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

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


パブリック コンストラクタパブリック コンストラクタ
プロテクト コンストラクタプロテクト コンストラクタ
  名前 説明
プロテクト メソッド NameValueCollection オーバーロードされますNameValueCollection クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Count  NameObjectCollectionBase インスタンス格納されているキーと値のペアの数を取得します。(NameObjectCollectionBase から継承されます。)
パブリック プロパティ Item オーバーロードされますNameValueCollection指定したエントリを取得または設定します
パブリック プロパティ Keys  NameObjectCollectionBase インスタンス内のすべてのキー格納する NameObjectCollectionBase.KeysCollection インスタンス取得します。(NameObjectCollectionBase から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ IsReadOnly  NameObjectCollectionBase インスタンス読み取り専用かどうかを示す値を取得または設定します。(NameObjectCollectionBase から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Add オーバーロードされます現在の NameValueCollection にエントリを追加します
パブリック メソッド Clear キャッシュ保存され配列無効化し、NameValueCollection からすべてのエントリを削除します
パブリック メソッド CopyTo NameValueCollection 全体互換性のある 1 次元Arrayコピーしますコピー操作は、コピー先の配列指定したインデックスから始まります
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド Get オーバーロードされますNameValueCollection 内で指定したエントリの値をいくつか取得し1 つコンマ区切りリスト組み合わせます。
パブリック メソッド GetEnumerator  NameObjectCollectionBase を反復処理する列挙子を返します。 (NameObjectCollectionBase から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetKey NameValueCollection指定したインデックスにあるキー取得します
パブリック メソッド GetObjectData  ISerializable インターフェイス実装し、NameObjectCollectionBase インスタンスシリアル化するために必要なデータ返します。 (NameObjectCollectionBase から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド GetValues オーバーロードされますNameValueCollection 内の指定したエントリの値を取得します
パブリック メソッド HasKeys NameValueCollection が、null 参照 (Visual Basic では Nothing) ではないキー格納しているかどうかを示す値を取得します
パブリック メソッド OnDeserialization  ISerializable インターフェイス実装し、逆シリアル化完了したときに逆シリアル化イベント発生させます。 (NameObjectCollectionBase から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Remove 指定したキーを持つエントリを NameObjectCollectionBase インスタンスか削除します
パブリック メソッド Set NameValueCollection 内のエントリの値を設定します
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド BaseAdd  指定したキーと値を持つエントリを NameObjectCollectionBase インスタンス追加します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseClear  NameObjectCollectionBase インスタンスかすべてのエントリを削除します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGet  オーバーロードされますNameObjectCollectionBase インスタンスから、指定したエントリの値を取得します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGetAllKeys  NameObjectCollectionBase インスタンス内のすべてのキー格納する String 配列返します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGetAllValues  オーバーロードされますNameObjectCollectionBase インスタンス内のすべての値を格納する配列返します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseGetKey  NameObjectCollectionBase インスタンス指定したインデックスにあるエントリのキー取得します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseHasKeys  NameObjectCollectionBase インスタンスが、キーnull 参照 (Visual Basic では Nothing) ではないエントリを格納しているかどうかを示す値を取得します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseRemove  指定したキーを持つエントリを NameObjectCollectionBase インスタンスか削除します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseRemoveAt  NameObjectCollectionBase インスタンス指定したインデックスにあるエントリを削除します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド BaseSet  オーバーロードされますNameObjectCollectionBase インスタンス内のエントリの値を設定します。 (NameObjectCollectionBase から継承されます。)
プロテクト メソッド Finalize  Objectガベージ コレクションにより収集される前に、その Objectリソース解放しその他のクリーンアップ操作実行できるようにします。 (Object から継承されます。)
プロテクト メソッド InvalidateCachedArrays コレクション内でキャッシュ保存され配列null 参照 (Visual Basic では Nothing) にリセットします。
プロテクト メソッド MemberwiseClone  現在の Object簡易コピー作成します。 (Object から継承されます。)
参照参照

関連項目

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

その他の技術情報

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



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

辞書ショートカット

すべての辞書の索引

「NameValueCollection」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS