本文整理汇总了C#中System.Duration.Divide方法的典型用法代码示例。如果您正苦于以下问题:C# Duration.Divide方法的具体用法?C# Duration.Divide怎么用?C# Duration.Divide使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Duration
的用法示例。
在下文中一共展示了Duration.Divide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDivisionByConstant
public void TestDivisionByConstant()
{
Duration duration = new Duration(500, 100.0);
Duration result = duration.Divide(100.0);
Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));
result = duration / 100.0;
Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));
duration = new Duration(5, 68010.0);
result = duration.Divide(100.0);
Assert.IsTrue(result.EqualsEpsilon(new Duration(0, 5000.1), Constants.Epsilon10));
result = duration / 100.0;
Assert.IsTrue(result.EqualsEpsilon(new Duration(0, 5000.1), Constants.Epsilon10));
duration = new Duration(0, 64800.0);
result = duration.Divide(0.5);
Assert.IsTrue(result.EqualsEpsilon(new Duration(1, 43200.0), Constants.Epsilon10));
result = duration / 0.5;
Assert.IsTrue(result.EqualsEpsilon(new Duration(1, 43200.0), Constants.Epsilon10));
duration = new Duration(502, 43300.5);
result = duration.Divide(100.5);
Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));
result = duration / 100.5;
Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));
duration = new Duration(5, 1.0);
result = duration / -2.0;
Assert.IsTrue(result.EqualsEpsilon(new Duration(-2, -43200.5), Constants.Epsilon10));
duration = new Duration(0, 18 * 3600);
result = duration / -0.5;
Assert.AreEqual(-12 * 3600, result.Seconds);
Assert.AreEqual(-1, result.Days);
duration = new Duration(1, 4 * 3600);
result = duration / -2;
Assert.AreEqual(-14 * 3600, result.Seconds);
Assert.AreEqual(0, result.Days);
}
示例2: TestDivisionByDuration
public void TestDivisionByDuration()
{
Duration one = new Duration(1, 0.0);
Duration two = new Duration(0, 60.0);
Assert.AreEqual(86400.0 / 60.0, one.Divide(two), Constants.Epsilon10);
Assert.AreEqual(60 / 86400.0, two / one, Constants.Epsilon10);
Duration three = new Duration(1, 43200.0);
Assert.AreEqual((86400 + 43200) / 60.0, three / two, Constants.Epsilon10);
Assert.AreEqual(60.0 / (86400.0 + 43200.0), two.Divide(three), Constants.Epsilon10);
Duration four = new Duration(1, 0);
Duration five = new Duration(0, -3600);
Assert.AreEqual(-24, four / five, Constants.Epsilon10);
Assert.AreEqual((-1.0 / 24.0), five / four, Constants.Epsilon10);
Duration six = new Duration(-2, 0);
Assert.AreEqual(-0.5, four / six);
Assert.AreEqual(48, six / five);
Duration seven = new Duration(0, -0.5);
Assert.AreEqual(-48*3600, four / seven);
}