Visual Basic (Declaration) | |
---|---|
Public NotInheritable Class BinaryComparer |
C# | |
---|---|
public sealed class BinaryComparer |
Library/Library.Test/TestBinaryComparer.cs
C# | Copy Code |
---|---|
List<byte[]> all = new List<byte[]>(); all.Add(null); all.Add(Guid.Empty.ToByteArray()); for (int i = 0; i < 1000; i++) all.Add(Guid.NewGuid().ToByteArray()); all.Sort(new BinaryComparer()); byte[] last = null; Assert.IsNull(all[0]); all.RemoveAt(0); foreach (byte[] entry in all) { if(last != null) Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0); Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0); } |
VB.NET | Copy Code |
---|---|
Dim all As New List(Of Byte())() all.Add(Nothing) all.Add(Guid.Empty.ToByteArray()) Dim i As Integer = 0 While i < 1000 all.Add(Guid.NewGuid().ToByteArray()) System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1) End While all.Sort(New BinaryComparer()) Dim last As Byte() = Nothing Assert.IsNull(all(0)) all.RemoveAt(0) For Each entry As Byte() In all If last <> Nothing Then Assert.IsTrue(StringComparer.Ordinal.Compare(Convert.ToBase64String(last), Convert.ToBase64String(entry)) < 0) End If Assert.IsTrue(BinaryComparer.Compare(last, entry) < 0) Next |
System.Object
CSharpTest.Net.Crypto.BinaryComparer
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
BinaryComparer MembersCSharpTest.Net.Crypto Namespace