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

CommaDelimitedStringCollection クラス

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

コンマで区切られた文字列要素のコレクションを表します。このクラスは継承できません。

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

Public NotInheritable Class
 CommaDelimitedStringCollection
    Inherits StringCollection
Dim instance As CommaDelimitedStringCollection
public sealed class CommaDelimitedStringCollection
 : StringCollection
public ref class CommaDelimitedStringCollection
 sealed : public StringCollection
public final class CommaDelimitedStringCollection
 extends StringCollection
public final class CommaDelimitedStringCollection
 extends StringCollection
解説解説
使用例使用例

CommaDelimitedStringCollection 型を使用する方法を次のコード例に示します。

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Configuration
Imports System.Collections.Specialized

Namespace Samples.AspNet.Config
  Class CommaDelimitedStrCollection
    Shared Sub Main(ByVal
 args() As String)
      ' Display title and info.
      Console.WriteLine("ASP.NET Configuration Info")
      Console.WriteLine("Type: CommaDelimitedStringCollection")
      Console.WriteLine()

      ' Set the path of the config file.
      Dim configPath As String
 = "/aspnet"

      ' Get the Web application configuration object.
      Dim config As Configuration = _
      WebConfigurationManager.OpenWebConfiguration(configPath)

      ' Get the section related object.
      Dim configSection As AuthorizationSection
 = _
      CType(config.GetSection("system.web/authorization"),
 AuthorizationSection)

      ' Get the authorization rule collection.
      Dim authorizationRuleCollection As AuthorizationRuleCollection
 = _
      configSection.Rules()

      ' Create a CommaDelimitedStringCollection object.
      Dim myStrCollection As CommaDelimitedStringCollection
 = _
        New CommaDelimitedStringCollection()

      Dim i As Integer
      For i = 0 To authorizationRuleCollection.Count
 - 1 Step i + 1
        If authorizationRuleCollection.Get(i).Action.ToString().ToLower()
 _
          = "allow" Then
          ' Add values to the CommaDelimitedStringCollection object.
          myStrCollection.AddRange( _
            authorizationRuleCollection.Get(i).Users.ToString().Split( _
            ",".ToCharArray()))
        End If
      Next

      Console.WriteLine("Allowed Users: {0}", _
        myStrCollection.ToString())

      ' Count the elements in the collection.
      Console.WriteLine("Allowed User Count: {0}",
 _
        myStrCollection.Count)

      ' Call the Contains method.
      Console.WriteLine("Contains 'userName1': {0}", _
        myStrCollection.Contains("userName1"))

      ' Determine the index of an element
      ' in the collection.
      Console.WriteLine("IndexOf 'userName0': {0}", _
        myStrCollection.IndexOf("userName0"))

      ' Call IsModified.
      Console.WriteLine("IsModified: {0}", _
        myStrCollection.IsModified)

      ' Call IsReadyOnly.
      Console.WriteLine("IsReadOnly: {0}", _
        myStrCollection.IsReadOnly)

      Console.WriteLine()
      Console.WriteLine("Add a user name to the collection.")
      ' Insert a new element in the collection.
      myStrCollection.Insert(myStrCollection.Count, "userNameX")

      Console.WriteLine("Collection Value: {0}", _
        myStrCollection.ToString())

      Console.WriteLine()
      Console.WriteLine("Remove a user name from the collection.")
      ' Remove an element of the collection.
      myStrCollection.Remove("userNameX")

      Console.WriteLine("Collection Value: {0}", _
        myStrCollection.ToString())

      ' Display and wait
      Console.ReadLine()
    End Sub
  End Class
End Namespace
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Configuration;
using System.Collections.Specialized;

namespace Samples.AspNet.Config
{
  class CommaDelimitedStrCollection
  {
    static void Main(string[]
 args)
    {
      // Display title and info.
      Console.WriteLine("ASP.NET Configuration Info");
      Console.WriteLine("Type: CommaDelimitedStringCollection");
      Console.WriteLine();

      // Set the path of the config file.
      string configPath = "/aspnet";

      // Get the Web application configuration object.
      Configuration config = 
        WebConfigurationManager.OpenWebConfiguration(configPath);

      // Get the section related object.
      AuthorizationSection configSection =
        (AuthorizationSection)config.GetSection("system.web/authorization");

      // Get the authorization rule collection.
      AuthorizationRuleCollection authorizationRuleCollection = 
        configSection.Rules;

      // Create a CommaDelimitedStringCollection object.
      CommaDelimitedStringCollection myStrCollection =
        new CommaDelimitedStringCollection();

      for (int i = 0; i < authorizationRuleCollection.Count;
 i++)
      {
        if (authorizationRuleCollection.Get(i).Action.ToString().ToLower()
 
          == "allow")
        {
          // Add values to the CommaDelimitedStringCollection object.
          myStrCollection.AddRange(
            authorizationRuleCollection.Get(i).Users.ToString().Split(
            ",".ToCharArray()));
        }
      }

      Console.WriteLine("Allowed Users: {0}",
        myStrCollection.ToString());

      // Count the elements in the collection.
      Console.WriteLine("Allowed User Count: {0}", 
        myStrCollection.Count);

      // Call the Contains method.
      Console.WriteLine("Contains 'userName1': {0}",
        myStrCollection.Contains("userName1"));

      // Determine the index of an element
      // in the collection.
      Console.WriteLine("IndexOf 'userName0': {0}",
        myStrCollection.IndexOf("userName0"));

      // Call IsModified.
      Console.WriteLine("IsModified: {0}",
        myStrCollection.IsModified);

      // Call IsReadyOnly.
      Console.WriteLine("IsReadOnly: {0}",
        myStrCollection.IsReadOnly);

      Console.WriteLine();
      Console.WriteLine("Add a user name to the collection.");
      // Insert a new element in the collection.
      myStrCollection.Insert(myStrCollection.Count, "userNameX");

      Console.WriteLine("Collection Value: {0}",
        myStrCollection.ToString());

      Console.WriteLine();
      Console.WriteLine("Remove a user name from the collection.");
      // Remove an element of the collection.
      myStrCollection.Remove("userNameX");

      Console.WriteLine("Collection Value: {0}",
        myStrCollection.ToString());

      // Display and wait
      Console.ReadLine();
    }
  }
}
継承階層継承階層
System.Object
   System.Collections.Specialized.StringCollection
    System.Configuration.CommaDelimitedStringCollection
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CommaDelimitedStringCollection メンバ
System.Configuration 名前空間
StringCollection

CommaDelimitedStringCollection コンストラクタ

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

CommaDelimitedStringCollection クラスの新しいインスタンスを作成します。

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

Dim instance As New CommaDelimitedStringCollection
public CommaDelimitedStringCollection ()
public:
CommaDelimitedStringCollection ()
public CommaDelimitedStringCollection ()
public function CommaDelimitedStringCollection
 ()
使用例使用例

CommaDelimitedStringCollection コンストラクタを使用する方法を次のコード例に示します。このコード例は CommaDelimitedStringCollection クラスの概要で取り上げているコード例の一部分です。

' Create a CommaDelimitedStringCollection object.
Dim myStrCollection As CommaDelimitedStringCollection
 = _
  New CommaDelimitedStringCollection()
// Create a CommaDelimitedStringCollection object.
CommaDelimitedStringCollection myStrCollection =
  new CommaDelimitedStringCollection();
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CommaDelimitedStringCollection クラス
CommaDelimitedStringCollection メンバ
System.Configuration 名前空間

CommaDelimitedStringCollection プロパティ


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

  名前 説明
パブリック プロパティ Count  StringCollection に格納されている文字列の数を取得します。 ( StringCollection から継承されます。)
パブリック プロパティ IsModified コレクションが変更されたかどうかを示す値を取得します。
パブリック プロパティ IsReadOnly コレクション オブジェクトが読み取り専用かどうかを示す値を取得します。
パブリック プロパティ IsSynchronized  StringCollection へのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。 ( StringCollection から継承されます。)
パブリック プロパティ Item インデックスに基づいてコレクション内の文字列要素を取得または設定します。
パブリック プロパティ SyncRoot  StringCollection へのアクセスを同期するために使用できるオブジェクトを取得します。 ( StringCollection から継承されます。)
参照参照

関連項目

CommaDelimitedStringCollection クラス
System.Configuration 名前空間
StringCollection

CommaDelimitedStringCollection メソッド


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

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Add コンマ区切りのコレクションに文字列を追加します。
パブリック メソッド AddRange 文字列配列のすべての文字列をコレクションに追加します。
パブリック メソッド Clear コレクションを空にします。
パブリック メソッド Clone コレクションのコピーを作成します。
パブリック メソッド Contains  指定した文字列が StringCollection 内にあるかどうかを確認します。 ( StringCollection から継承されます。)
パブリック メソッド CopyTo  1 次元の文字列配列に、その配列内の指定したインデックスを開始位置として StringCollection 値全体をコピーします。 ( StringCollection から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator  StringCollection を反復処理する StringEnumerator を返します。 ( StringCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド IndexOf  指定した文字列を検索し、StringCollection 内でその文字列が最初に見つかった位置の 0 から始まるインデックスを返します。 ( StringCollection から継承されます。)
パブリック メソッド Insert コレクション内の指定したインデックス位置に、文字列要素を追加します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Remove 文字列要素をコレクションから削除します。
パブリック メソッド RemoveAt  StringCollection 内の指定したインデックスにある文字列を削除します。 ( StringCollection から継承されます。)
パブリック メソッド SetReadOnly コレクション オブジェクトを読み取り専用に設定します。
パブリック メソッド ToString オーバーライドされます。 オブジェクトの文字列形式を返します。
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CommaDelimitedStringCollection クラス
System.Configuration 名前空間
StringCollection

CommaDelimitedStringCollection メンバ

コンマで区切られた文字列要素のコレクションを表します。このクラスは継承できません。

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


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド CommaDelimitedStringCollection CommaDelimitedStringCollection クラスの新しいインスタンスを作成します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Count  StringCollection に格納されている文字列の数を取得します。(StringCollection から継承されます。)
パブリック プロパティ IsModified コレクションが変更されたかどうかを示す値を取得します。
パブリック プロパティ IsReadOnly コレクション オブジェクトが読み取り専用かどうかを示す値を取得します。
パブリック プロパティ IsSynchronized  StringCollection へのアクセスが同期されている (スレッド セーフである) かどうかを示す値を取得します。(StringCollection から継承されます。)
パブリック プロパティ Item インデックスに基づいてコレクション内の文字列要素を取得または設定します。
パブリック プロパティ SyncRoot  StringCollection へのアクセスを同期するために使用できるオブジェクトを取得します。(StringCollection から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド Add コンマ区切りのコレクションに文字列を追加します。
パブリック メソッド AddRange 文字列配列のすべての文字列をコレクションに追加します。
パブリック メソッド Clear コレクションを空にします。
パブリック メソッド Clone コレクションのコピーを作成します。
パブリック メソッド Contains  指定した文字列が StringCollection 内にあるかどうかを確認します。 (StringCollection から継承されます。)
パブリック メソッド CopyTo  1 次元の文字列配列に、その配列内の指定したインデックスを開始位置として StringCollection 値全体をコピーします。 (StringCollection から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator  StringCollection を反復処理する StringEnumerator を返します。 (StringCollection から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド IndexOf  指定した文字列を検索し、StringCollection 内でその文字列が最初に見つかった位置の 0 から始まるインデックスを返します。 (StringCollection から継承されます。)
パブリック メソッド Insert コレクション内の指定したインデックス位置に、文字列要素を追加します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド Remove 文字列要素をコレクションから削除します。
パブリック メソッド RemoveAt  StringCollection 内の指定したインデックスにある文字列を削除します。 (StringCollection から継承されます。)
パブリック メソッド SetReadOnly コレクション オブジェクトを読み取り専用に設定します。
パブリック メソッド ToString オーバーライドされます。 オブジェクトの文字列形式を返します。
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

CommaDelimitedStringCollection クラス
System.Configuration 名前空間
StringCollection


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

英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「CommaDelimitedStringCollection」の関連用語

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

   

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



CommaDelimitedStringCollectionのページの著作権

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

©2026 GRAS Group, Inc.RSS