本文整理汇总了C#中Edu.Wisc.Forest.Flel.Util.Percentage.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Percentage.ToString方法的具体用法?C# Percentage.ToString怎么用?C# Percentage.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Edu.Wisc.Forest.Flel.Util.Percentage
的用法示例。
在下文中一共展示了Percentage.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoubleCtor
public void DoubleCtor()
{
Percentage percentage = new Percentage(0.567);
Assert.AreEqual(0.567, percentage.Value);
Assert.AreEqual(0.567, (double) percentage);
Assert.AreEqual("56.7%", percentage.ToString());
}
示例2: DefaultCtor
public void DefaultCtor()
{
Percentage percentage = new Percentage();
Assert.AreEqual(0.0, percentage.Value);
Assert.AreEqual(0.0, (double) percentage);
Assert.AreEqual("0%", percentage.ToString());
}
示例3: ValidatePercentage
//---------------------------------------------------------------------
private void ValidatePercentage(Percentage percentage)
{
if (percentage < 0.0 || percentage > 1.0)
throw new InputValueException(percentage.ToString(),
"Value must be between 0% and 100%");
}
示例4: Check50Percent
//---------------------------------------------------------------------
private void Check50Percent(Percentage percentage)
{
Assert.AreEqual(0.50, percentage.Value);
Assert.AreEqual("50%", percentage.ToString());
Assert.AreEqual("50%", string.Format("{0}", percentage));
Assert.AreEqual("50%", string.Format("{0:%}", percentage));
Assert.AreEqual("50.0%", string.Format("{0:#.0%}", percentage));
Assert.AreEqual(".500", string.Format("{0:#.##0}", percentage));
Assert.AreEqual(".5", string.Format("{0:#.###}", percentage));
Assert.AreEqual("0.50", string.Format("{0:0.#0}", percentage));
}
示例5: PercentageMin
public void PercentageMin()
{
Percentage percentage = new Percentage(Percentage.MinValueAsDouble);
Assert.AreEqual(string.Format("{0}%", double.MinValue),
percentage.ToString());
}