本文整理汇总了C#中System.Variant.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Variant.CompareTo方法的具体用法?C# Variant.CompareTo怎么用?C# Variant.CompareTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Variant
的用法示例。
在下文中一共展示了Variant.CompareTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestListComparison
public void TestListComparison()
{
Variant v1 = new Variant(Variant.EnumType.List);
v1.Add(new Variant("value1"));
v1.Add(new Variant("value2"));
Variant v2 = new Variant(Variant.EnumType.List);
v2.Add(new Variant("value2"));
v2.Add(new Variant("value1"));
Assert.AreEqual(0, v1.CompareTo(v1));
Assert.AreEqual(-1, v1.CompareTo(v2));
Assert.AreEqual(1, v2.CompareTo(v1));
}
示例2: TestTSComparison
public void TestTSComparison()
{
Variant v1 = new Variant(Variant.EnumType.TimeSeries);
v1.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value1"));
v1.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value2"));
Variant v2 = new Variant(Variant.EnumType.TimeSeries);
v2.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1"));
v2.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2"));
Variant v3 = new Variant(Variant.EnumType.TimeSeries);
v3.Add(new DateTime(2010, 1, 2, 3, 4, 5, 6), new Variant("value2"));
v3.Add(new DateTime(2010, 1, 3, 3, 4, 5, 6), new Variant("value1"));
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: TestBagComparison
public void TestBagComparison()
{
Variant v1 = new Variant(Variant.EnumType.Bag);
v1.Add("key1", new Variant("value1"));
v1.Add("key2", new Variant("value2"));
Variant v2 = new Variant(Variant.EnumType.Bag);
v2.Add("key1", new Variant("value1"));
v2.Add("key2", new Variant("value2"));
Variant v3 = new Variant(Variant.EnumType.Bag);
v3.Add("key2", new Variant("value1"));
v3.Add("key3", new Variant("value2"));
Variant v4 = new Variant(Variant.EnumType.Bag);
v4.Add("key1", new Variant("value2"));
v4.Add("key2", new Variant("value3"));
Assert.AreEqual(0, v1.CompareTo(v2));
Assert.AreEqual(-1, v1.CompareTo(v3));
Assert.AreEqual(1, v3.CompareTo(v1));
Assert.AreEqual(-1, v1.CompareTo(v4));
Assert.AreEqual(1, v4.CompareTo(v1));
}
示例4: TestComparison
public void TestComparison()
{
System.Data.DataTable dt1 = new DataTable();
dt1.Columns.Add(new DataColumn("Double", typeof(double)));
dt1.Columns.Add(new DataColumn("String", typeof(string)));
DataRow dr1 = dt1.NewRow();
dr1[0] = 1.0;
dr1[1] = "value";
dt1.Rows.Add(dr1);
Variant v1 = new Variant(dt1);
System.Data.DataTable dt2 = new DataTable();
dt2.Columns.Add(new DataColumn("Double", typeof(double)));
dt2.Columns.Add(new DataColumn("String", typeof(string)));
DataRow dr2 = dt2.NewRow();
dr2[0] = 1.0;
dr2[1] = "value";
dt2.Rows.Add(dr2);
Variant v2 = new Variant(dt2);
System.Data.DataTable dt3 = new DataTable();
dt3.Columns.Add(new DataColumn("Double", typeof(double)));
dt3.Columns.Add(new DataColumn("String", typeof(string)));
DataRow dr3 = dt3.NewRow();
dr3[0] = 2.0;
dr3[1] = "value";
dt3.Rows.Add(dr3);
Variant v3 = new Variant(dt3);
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));
}
示例5: TestTupleComparison
public void TestTupleComparison()
{
Variant v1 = new Variant(Variant.EnumType.Tuple, 2);
v1[0] = new Variant("value1");
v1[1] = new Variant("value2");
Variant v2 = new Variant(Variant.EnumType.Tuple, 2);
v2[0] = new Variant("value2");
v2[1] = new Variant("value1");
Assert.AreEqual(0, v1.CompareTo(v1));
Assert.AreEqual(-1, v1.CompareTo(v2));
Assert.AreEqual(1, v2.CompareTo(v1));
}