本文整理汇总了C#中X509CertificateCollection.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# X509CertificateCollection.CopyTo方法的具体用法?C# X509CertificateCollection.CopyTo怎么用?C# X509CertificateCollection.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X509CertificateCollection
的用法示例。
在下文中一共展示了X509CertificateCollection.CopyTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: X509CertificateCollectionCopyTo
public static void X509CertificateCollectionCopyTo()
{
using (X509Certificate c1 = new X509Certificate())
using (X509Certificate c2 = new X509Certificate())
using (X509Certificate c3 = new X509Certificate())
{
X509CertificateCollection cc = new X509CertificateCollection(new X509Certificate[] { c1, c2, c3 });
X509Certificate[] array1 = new X509Certificate[cc.Count];
cc.CopyTo(array1, 0);
Assert.Same(c1, array1[0]);
Assert.Same(c2, array1[1]);
Assert.Same(c3, array1[2]);
X509Certificate[] array2 = new X509Certificate[cc.Count];
((ICollection)cc).CopyTo(array2, 0);
Assert.Same(c1, array2[0]);
Assert.Same(c2, array2[1]);
Assert.Same(c3, array2[2]);
}
}
示例2: X509CertificateCollectionThrowsArgumentNullException
public static void X509CertificateCollectionThrowsArgumentNullException()
{
using (X509Certificate certificate = new X509Certificate())
{
Assert.Throws<ArgumentNullException>(() => new X509CertificateCollection((X509Certificate[])null));
Assert.Throws<ArgumentNullException>(() => new X509CertificateCollection((X509CertificateCollection)null));
X509CertificateCollection collection = new X509CertificateCollection { certificate };
Assert.Throws<ArgumentNullException>(() => collection[0] = null);
Assert.Throws<ArgumentNullException>(() => collection.Add(null));
Assert.Throws<ArgumentNullException>(() => collection.AddRange((X509Certificate[])null));
Assert.Throws<ArgumentNullException>(() => collection.AddRange((X509CertificateCollection)null));
Assert.Throws<ArgumentNullException>(() => collection.CopyTo(null, 0));
Assert.Throws<ArgumentNullException>(() => collection.Insert(0, null));
Assert.Throws<ArgumentNullException>(() => collection.Remove(null));
IList ilist = (IList)collection;
Assert.Throws<ArgumentNullException>(() => ilist[0] = null);
Assert.Throws<ArgumentNullException>(() => ilist.Add(null));
Assert.Throws<ArgumentNullException>(() => ilist.CopyTo(null, 0));
Assert.Throws<ArgumentNullException>(() => ilist.Insert(0, null));
Assert.Throws<ArgumentNullException>(() => ilist.Remove(null));
}
Assert.Throws<ArgumentNullException>(() => new X509CertificateCollection.X509CertificateEnumerator(null));
}