本文整理匯總了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));
}