本文整理汇总了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());
}