本文整理汇总了C#中Amount.Power方法的典型用法代码示例。如果您正苦于以下问题:C# Amount.Power方法的具体用法?C# Amount.Power怎么用?C# Amount.Power使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amount
的用法示例。
在下文中一共展示了Amount.Power方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Scenario05Test
public void Scenario05Test()
{
// Scenario calculating stop-distance:
// A car drives at 120 km/h. What distance does the car need to stop
// at a deceleration of 6m/s² if the driver needs 1 second to react ?
// Parameters:
Amount speed = new Amount(120, LengthUnits.KiloMeter / TimeUnits.Hour);
Amount reactiontime = new Amount(1, TimeUnits.Second);
Amount deceleration = new Amount(6, LengthUnits.Meter / TimeUnits.Second.Power(2));
// Formula:
Amount distance;
distance = (speed * reactiontime) + speed.Power(2) / (2 * deceleration);
Console.WriteLine("Distance : {0}", distance);
Console.WriteLine("Distance : {0}", distance.ConvertedTo(LengthUnits.Meter, 1));
// Result:
Assert.AreEqual(new Amount(125.9m, LengthUnits.Meter), distance.ConvertedTo(LengthUnits.Meter, 1));
}