本文整理匯總了C#中System.Duration.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# Duration.ToString方法的具體用法?C# Duration.ToString怎麽用?C# Duration.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Duration
的用法示例。
在下文中一共展示了Duration.ToString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestToString
public void TestToString()
{
Duration duration = new Duration(1, 43200.0);
Assert.AreEqual(duration.ToString(), "1:43200");
}
示例2: MonthsToString
[Test] public void MonthsToString ()
{
Duration d = new Duration(5, Duration.Unit.Months);
Assert.AreEqual("5 Months", d.ToString());
}
示例3: DaysToString
[Test] public void DaysToString ()
{
Duration d = new Duration(5, Duration.Unit.Days);
Assert.AreEqual("5 Days", d.ToString());
}
示例4: WeeksToString
[Test] public void WeeksToString ()
{
Duration d = new Duration(5, Duration.Unit.Weeks);
Assert.AreEqual("5 Weeks", d.ToString());
}
示例5: ToString_NonNormalized
public void ToString_NonNormalized()
{
// Just a single example should be sufficient...
var duration = new Duration { Seconds = 1, Nanos = -1 };
Assert.AreEqual("{ \"@warning\": \"Invalid Duration\", \"seconds\": \"1\", \"nanos\": -1 }", duration.ToString());
}