X509ChainElementCollection.Count X509ChainElementCollection.Count X509ChainElementCollection.Count X509ChainElementCollection.Count Property

Определение

Возвращает количество элементов в коллекции.Gets the number of elements in the collection.

public:
 property int Count { int get(); };
public int Count { get; }
member this.Count : int
Public ReadOnly Property Count As Integer

Значение свойства

Целое число, представляющее количество элементов в коллекции.An integer representing the number of elements in the collection.

Реализации

Примеры

В следующем примере кода открывается хранилище личных сертификатов текущего пользователя, позволяет пользователю выбрать сертификат и затем записывает сертификат и информация о цепочке сертификатов на консоль.The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. Выходные данные зависят от выбранного сертификата.The output depends on the certificate you select.

//Output chain element information.
Console::WriteLine( "Chain Element Information" );
Console::WriteLine( "Number of chain elements: {0}", ch->ChainElements->Count );
Console::WriteLine( "Chain elements synchronized? {0} {1}", ch->ChainElements->IsSynchronized, Environment::NewLine );
System::Collections::IEnumerator^ myEnum = ch->ChainElements->GetEnumerator();
while ( myEnum->MoveNext() )
{
   X509ChainElement ^ element = safe_cast<X509ChainElement ^>(myEnum->Current);
   Console::WriteLine( "Element issuer name: {0}", element->Certificate->Issuer );
   Console::WriteLine( "Element certificate valid until: {0}", element->Certificate->NotAfter );
   Console::WriteLine( "Element certificate is valid: {0}", element->Certificate->Verify() );
   Console::WriteLine( "Element error status length: {0}", element->ChainElementStatus->Length );
   Console::WriteLine( "Element information: {0}", element->Information );
   Console::WriteLine( "Number of element extensions: {0}{1}", element->Certificate->Extensions->Count, Environment::NewLine );
   if ( ch->ChainStatus->Length > 1 )
   {
      for ( int index = 0; index < element->ChainElementStatus->Length; index++ )
      {
         Console::WriteLine( element->ChainElementStatus[ index ].Status );
         Console::WriteLine( element->ChainElementStatus[ index ].StatusInformation );
      }
   }
}

store->Close();
//Output chain element information.
Console.WriteLine ("Chain Element Information");
Console.WriteLine ("Number of chain elements: {0}", ch.ChainElements.Count);
Console.WriteLine ("Chain elements synchronized? {0} {1}", ch.ChainElements.IsSynchronized, Environment.NewLine);

foreach (X509ChainElement element in ch.ChainElements)
{
	Console.WriteLine ("Element issuer name: {0}", element.Certificate.Issuer);
	Console.WriteLine ("Element certificate valid until: {0}", element.Certificate.NotAfter);
	Console.WriteLine ("Element certificate is valid: {0}", element.Certificate.Verify ());
	Console.WriteLine ("Element error status length: {0}", element.ChainElementStatus.Length);
	Console.WriteLine ("Element information: {0}", element.Information);
	Console.WriteLine ("Number of element extensions: {0}{1}", element.Certificate.Extensions.Count, Environment.NewLine);

	if (ch.ChainStatus.Length > 1)
	{
		for (int index = 0; index < element.ChainElementStatus.Length; index++)
		{
			Console.WriteLine (element.ChainElementStatus[index].Status);
			Console.WriteLine (element.ChainElementStatus[index].StatusInformation);
		}
	}
}
store.Close();
'Output chain element information.
Console.WriteLine("Chain Element Information")
Console.WriteLine("Number of chain elements: {0}", ch.ChainElements.Count)
Console.WriteLine("Chain elements synchronized? {0} {1}", ch.ChainElements.IsSynchronized, Environment.NewLine)

Dim element As X509ChainElement
For Each element In ch.ChainElements
    Console.WriteLine("Element issuer name: {0}", element.Certificate.Issuer)
    Console.WriteLine("Element certificate valid until: {0}", element.Certificate.NotAfter)
    Console.WriteLine("Element certificate is valid: {0}", element.Certificate.Verify())
    Console.WriteLine("Element error status length: {0}", element.ChainElementStatus.Length)
    Console.WriteLine("Element information: {0}", element.Information)
    Console.WriteLine("Number of element extensions: {0}{1}", element.Certificate.Extensions.Count, Environment.NewLine)

    If ch.ChainStatus.Length > 1 Then
        Dim index As Integer
        For index = 0 To element.ChainElementStatus.Length
            Console.WriteLine(element.ChainElementStatus(index).Status)
            Console.WriteLine(element.ChainElementStatus(index).StatusInformation)
        Next index
    End If
Next element
store.Close()

Комментарии

Используйте это свойство позволяет определить количество элементов в коллекции.Use this property to determine how many elements are in the collection.

Применяется к