本文整理汇总了C#中Variant.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.CompareTo方法的具体用法?C# Variant.CompareTo怎么用?C# Variant.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variant
的用法示例。
在下文中一共展示了Variant.CompareTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestComparison
public void TestComparison()
{
Variant v1 = new Variant(new TestObject1("some value"));
Variant v2 = new Variant(new TestObject1("some other value"));
Variant v3 = new Variant(new TestObject2("some value"));
Assert.AreEqual(0, v1.CompareTo(v1));
Assert.AreEqual(1, v1.CompareTo(v2));
Assert.AreEqual(-1, v2.CompareTo(v1));
Assert.AreEqual(-1, v1.CompareTo(v3));
Assert.AreEqual(1, v3.CompareTo(v1));
}
示例2: TestComparison
public void TestComparison()
{
Variant v1 = new Variant(new byte[] { 0x01, 0x02, 0x03 });
Variant v2 = new Variant(new byte[] { 0x01, 0x02, 0x04 });
Variant v3 = new Variant(new byte[] { 0x01, 0x02, 0x03, 0x04 });
Assert.AreEqual(0, v1.CompareTo(v1));
Assert.AreEqual(-1, v1.CompareTo(v2));
Assert.AreEqual(1, v2.CompareTo(v1));
Assert.AreEqual(-1, v1.CompareTo(v3));
Assert.AreEqual(1, v3.CompareTo(v1));
}
示例3: TestComparison
public void TestComparison()
{
TypedArray a1 = new TypedArray(Variant.EnumType.Double, 2);
a1[0] = 1.0;
a1[1] = 2.0;
Variant v1 = new Variant(a1);
TypedArray a2 = new TypedArray(Variant.EnumType.Double, 2);
a2[0] = 1.0;
a2[1] = 2.0;
Variant v2 = new Variant(a2);
TypedArray a3 = new TypedArray(Variant.EnumType.Double, 2);
a3[0] = 2.0;
a3[1] = 1.0;
Variant v3 = new Variant(a3);
Assert.IsTrue(v1.Equals(v2));
Assert.IsFalse(v1.Equals(v3));
Assert.AreEqual(0, v1.CompareTo(v2));
Assert.AreEqual(-1, v2.CompareTo(v3));
Assert.AreEqual(1, v3.CompareTo(v2));
}