CommaDelimitedStringCollection Sınıf

Tanım

Virgülle ayrılmış bir dize öğeleri koleksiyonunu temsil eder. Bu sınıf devralınamaz.

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
Devralma
CommaDelimitedStringCollection

Örnekler

Aşağıdaki kod örneğinde türün nasıl kullanılacağı gösterilmektedir 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

Açıklamalar

Bu sınıf, virgülle ayrılmış dize öğelerinin listesi olarak serileştirilmiş bir dize koleksiyonunu temsil eder.

Oluşturucular

Name Description
CommaDelimitedStringCollection()

sınıfının yeni bir örneğini CommaDelimitedStringCollection oluşturur.

Özellikler

Name Description
Count

içinde StringCollectionyer alan dize sayısını alır.

(Devralındığı yer: StringCollection)
IsModified

Koleksiyonun değiştirilip değiştirilmediğini belirten bir değer alır.

IsReadOnly

Koleksiyon nesnesinin salt okunur olup olmadığını belirten bir değer alır.

IsSynchronized

'a StringCollection erişimin eşitlenip eşitlenmediğini belirten bir değer alır (iş parçacığı güvenli).

(Devralındığı yer: StringCollection)
Item[Int32]

Dizine göre koleksiyondaki bir dize öğesini alır veya ayarlar.

SyncRoot

StringCollectionerişimini eşitlemek için kullanılabilecek bir nesnesi alır.

(Devralındığı yer: StringCollection)

Yöntemler

Name Description
Add(String)

Virgülle ayrılmış koleksiyona bir dize ekler.

AddRange(String[])

Dize dizisindeki tüm dizeleri koleksiyona ekler.

Clear()

Koleksiyonu temizler.

Clone()

Koleksiyonun bir kopyasını oluşturur.

Contains(String)

Belirtilen dizenin içinde StringCollectionolup olmadığını belirler.

(Devralındığı yer: StringCollection)
CopyTo(String[], Int32)

Değerlerin tamamını StringCollection , hedef dizinin belirtilen dizininden başlayarak tek boyutlu bir dize dizisine kopyalar.

(Devralındığı yer: StringCollection)
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetEnumerator()

aracılığıyla StringEnumeratoryineleyen bir StringCollection döndürür.

(Devralındığı yer: StringCollection)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
IndexOf(String)

Belirtilen dizeyi arar ve içindeki ilk oluşumun sıfır tabanlı dizinini StringCollectiondöndürür.

(Devralındığı yer: StringCollection)
Insert(Int32, String)

Belirtilen dizindeki koleksiyona bir dize öğesi ekler.

MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
Remove(String)

Koleksiyondan bir dize öğesi kaldırır.

RemoveAt(Int32)

dizesini belirtilen dizininde StringCollectionkaldırır.

(Devralındığı yer: StringCollection)
SetReadOnly()

Koleksiyon nesnesini salt okunur olarak ayarlar.

ToString()

Nesnenin dize gösterimini döndürür.

Belirtik Arabirim Kullanımları

Name Description
ICollection.CopyTo(Array, Int32)

Hedef dizinin belirtilen dizininden başlayarak tamamını StringCollection uyumlu bir tek boyutluya Arraykopyalar.

(Devralındığı yer: StringCollection)
IEnumerable.GetEnumerator()

aracılığıyla IEnumeratoryineleyen bir StringCollection döndürür.

(Devralındığı yer: StringCollection)
IList.Add(Object)

sonuna bir nesne StringCollectionekler.

(Devralındığı yer: StringCollection)
IList.Contains(Object)

Bir öğenin içinde StringCollectionolup olmadığını belirler.

(Devralındığı yer: StringCollection)
IList.IndexOf(Object)

Belirtilen Object öğesini arar ve içindeki StringCollectionilk oluşumun sıfır tabanlı dizinini döndürür.

(Devralındığı yer: StringCollection)
IList.Insert(Int32, Object)

Belirtilen dizinde öğesine StringCollection bir öğe ekler.

(Devralındığı yer: StringCollection)
IList.IsFixedSize

Nesnenin sabit bir boyuta StringCollection sahip olup olmadığını belirten bir değer alır.

(Devralındığı yer: StringCollection)
IList.IsReadOnly

Nesnenin StringCollection salt okunur olup olmadığını gösteren bir değer alır.

(Devralındığı yer: StringCollection)
IList.Item[Int32]

Belirtilen dizinde öğesini alır veya ayarlar.

(Devralındığı yer: StringCollection)
IList.Remove(Object)

Belirli bir nesnenin ilk oluşumunu öğesinden StringCollectionkaldırır.

(Devralındığı yer: StringCollection)

Uzantı Metotları

Name Description
AsParallel(IEnumerable)

Sorgunun paralelleştirilmesini etkinleştirir.

AsQueryable(IEnumerable)

bir IEnumerable öğesine IQueryabledönüştürür.

Cast<TResult>(IEnumerable)

öğesinin IEnumerable öğelerini belirtilen türe yazar.

OfType<TResult>(IEnumerable)

Belirtilen türe göre bir IEnumerable öğesinin öğelerini filtreler.

Şunlara uygulanır

Ayrıca bkz.