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되는 문자열 컬렉션을 나타냅니다.

생성자

Name Description
CommaDelimitedStringCollection()

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

속성

Name Description
Count

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

(다음에서 상속됨 StringCollection)
IsModified

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

IsReadOnly

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

IsSynchronized

StringCollection 대한 액세스가 동기화되는지 여부를 나타내는 값을 가져옵니다(스레드로부터 안전).

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

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

SyncRoot

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

(다음에서 상속됨 StringCollection)

메서드

Name Description
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)

지정된 문자열을 검색하고 0부터 시작하는 인덱스( StringCollection0부터 시작)를 반환합니다.

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

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

MemberwiseClone()

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

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

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

RemoveAt(Int32)

지정된 인덱 StringCollection스의 문자열을 제거합니다.

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

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

ToString()

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

명시적 인터페이스 구현

Name Description
ICollection.CopyTo(Array, Int32)

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

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

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

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

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

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

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

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

지정한 Object 인덱스(0부터 시작)를 검색하여 전체에서 첫 번째 항목의 인덱스(0부터 시작)를 반환합니다 StringCollection.

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

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

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

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

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

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

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

지정된 인덱스에서 요소를 가져오거나 설정합니다.

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

에서 특정 개체의 첫 번째 항목을 제거합니다 StringCollection.

(다음에서 상속됨 StringCollection)

확장명 메서드

Name Description
AsParallel(IEnumerable)

쿼리의 병렬 처리를 사용하도록 설정합니다.

AsQueryable(IEnumerable)

IEnumerable IQueryable변환합니다.

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

적용 대상

추가 정보