CommaDelimitedStringCollection 클래스

정의

쉼표로 구분된 문자열 요소의 컬렉션을 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class CommaDelimitedStringCollection sealed : System::Collections::Specialized::StringCollection
public sealed class CommaDelimitedStringCollection : System.Collections.Specialized.StringCollection
type CommaDelimitedStringCollection = class
    inherit StringCollection
Public NotInheritable Class CommaDelimitedStringCollection
Inherits StringCollection
상속
CommaDelimitedStringCollection

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 CommaDelimitedStringCollection 형식입니다.

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();
    }
  }
}
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

설명

이 클래스는 문자열 요소의 쉼표로 구분된 목록으로 serialize되는 문자열 컬렉션을 나타냅니다.

생성자

CommaDelimitedStringCollection()

CommaDelimitedStringCollection 클래스의 새 인스턴스를 만듭니다.

속성

Count

StringCollection에 포함된 문자열 수를 가져옵니다.

(다음에서 상속됨 StringCollection)
IsModified

컬렉션이 수정되었는지 여부를 지정하는 값을 가져옵니다.

IsReadOnly

컬렉션 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

IsSynchronized

StringCollection에 대한 액세스가 동기화되어 스레드로부터 안전하게 보호되는지를 나타내는 값을 가져옵니다.

(다음에서 상속됨 StringCollection)
Item[Int32]

인덱스를 기반으로 컬렉션의 문자열 요소를 가져오거나 설정합니다.

SyncRoot

StringCollection에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다.

(다음에서 상속됨 StringCollection)

메서드

Add(String)

쉼표로 구분된 컬렉션에 문자열을 추가합니다.

AddRange(String[])

문자열 배열의 모든 문자열을 컬렉션에 추가합니다.

Clear()

컬렉션을 지웁니다.

Clone()

컬렉션의 복사본을 만듭니다.

Contains(String)

지정한 문자열이 StringCollection에 있는지 여부를 확인합니다.

(다음에서 상속됨 StringCollection)
CopyTo(String[], Int32)

대상 배열의 지정한 인덱스에서 시작하여 전체 StringCollection 값을 1차원 문자열 배열에 복사합니다.

(다음에서 상속됨 StringCollection)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

StringEnumerator을 반복하는 StringCollection를 반환합니다.

(다음에서 상속됨 StringCollection)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IndexOf(String)

지정한 문자열을 검색하고 StringCollection 내에서 처음 나오는 0부터 시작하는 인덱스를 반환합니다.

(다음에서 상속됨 StringCollection)
Insert(Int32, String)

컬렉션의 지정된 인덱스에 문자열 요소를 추가합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Remove(String)

컬렉션에서 문자열 요소를 제거합니다.

RemoveAt(Int32)

StringCollection의 지정한 인덱스에 있는 문자열을 제거합니다.

(다음에서 상속됨 StringCollection)
SetReadOnly()

컬렉션 개체를 읽기 전용으로 설정합니다.

ToString()

개체의 문자열 표현을 반환합니다.

명시적 인터페이스 구현

ICollection.CopyTo(Array, Int32)

대상 배열의 지정된 인덱스에서 시작하여 전체 StringCollection을 호환되는 1차원 Array에 복사합니다.

(다음에서 상속됨 StringCollection)
IEnumerable.GetEnumerator()

IEnumerator을 반복하는 StringCollection를 반환합니다.

(다음에서 상속됨 StringCollection)
IList.Add(Object)

개체를 StringCollection의 끝 부분에 추가합니다.

(다음에서 상속됨 StringCollection)
IList.Contains(Object)

StringCollection에 요소가 있는지 여부를 확인합니다.

(다음에서 상속됨 StringCollection)
IList.IndexOf(Object)

지정한 Object를 검색하고, 전체 StringCollection 내에서 처음 나오는 0부터 시작하는 인덱스를 반환합니다.

(다음에서 상속됨 StringCollection)
IList.Insert(Int32, Object)

StringCollection의 지정된 인덱스에 요소를 삽입합니다.

(다음에서 상속됨 StringCollection)
IList.IsFixedSize

StringCollection 개체의 크기가 고정되어 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 StringCollection)
IList.IsReadOnly

StringCollection 개체가 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 StringCollection)
IList.Item[Int32]

지정한 인덱스에 있는 요소를 가져오거나 설정합니다.

(다음에서 상속됨 StringCollection)
IList.Remove(Object)

StringCollection에서 맨 처음 발견되는 특정 개체를 제거합니다.

(다음에서 상속됨 StringCollection)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보