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