当前位置: 首页>>代码示例>>C#>>正文


C# Amount.ToString方法代码示例

本文整理汇总了C#中Amount.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Amount.ToString方法的具体用法?C# Amount.ToString怎么用?C# Amount.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amount的用法示例。


在下文中一共展示了Amount.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToString_3

 public void ToString_3()
 {
    var amt = new Amount("usd", -122M);
                          
    Console.WriteLine(amt);    
    Assert.AreEqual("-122:usd", amt.ToString());    
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:7,代码来源:AmountTests.cs

示例2: ToString_1

 public void ToString_1()
 {
    var amt = new Amount("usd", 12.45M);
                          
    Console.WriteLine(amt);    
    Assert.AreEqual("12.45:usd", amt.ToString());    
 }
开发者ID:sergey-msu,项目名称:nfx,代码行数:7,代码来源:AmountTests.cs

示例3: DebitAmountToString

 public void DebitAmountToString()
 {
     var amount = new Amount(_account, EntryType.Debit, 10M);
     Assert.That(amount.ToString(), Is.EqualTo("Bank: 10.00 Dr"));
 }
开发者ID:andy-uq,项目名称:HomeTrack,代码行数:5,代码来源:AmountTests.cs

示例4: Formatting01Test

        public void Formatting01Test()
        {
            CultureInfo defaultCultureInfo = Thread.CurrentThread.CurrentCulture;
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                CultureInfo nlbe = CultureInfo.GetCultureInfo("nl-BE");
                CultureInfo enus = CultureInfo.GetCultureInfo("en-US");

                Amount a = new Amount(12.3456789m, LengthUnits.KiloMeter);
                Amount b = new Amount(12345.6789m, LengthUnits.Meter);
                Amount c = new Amount(-0.45m, LengthUnits.KiloMeter / TimeUnits.Hour);
                Amount d = new Amount(25.678m, LengthUnits.Meter * LengthUnits.Meter);

                Assert.AreEqual("12.3456789 km", a.ToString());
                Assert.AreEqual("12,3456789 kilometer", a.ToString("GN", nlbe));
                Assert.AreEqual("12,35 kilometer", a.ToString("NN", nlbe));
                Assert.AreEqual("12,35 km", a.ToString("NL", nlbe));
                Assert.AreEqual("12.35 km", a.ToString("NL", enus));
                Assert.AreEqual("12.345,68 m", b.ToString("NL", nlbe));
                Assert.AreEqual("12,345.68 m", b.ToString("NL", enus));
                Assert.AreEqual("-0.45 km/h", c.ToString("NL", enus));
                Assert.AreEqual("-0.45 (kilometer/hour)", c.ToString("NN", enus));
                Assert.AreEqual("-0,450 km/h", c.ToString("0.000 UL", nlbe));
                Assert.AreEqual("[0,450] km/h", c.ToString("0.000 UL;[0.000] UL", nlbe));
                Assert.AreEqual("12346 m", b.ToString("0 UL"));
                Assert.AreEqual("12.35 kilometer", b.ToString("NN|kilometer"));
                Assert.AreEqual("12.346 km", b.ToString("#,##0.000 UL|kilometer"));
                Assert.AreEqual("+12.346 km", b.ToString("+#,##0.000 UL|kilometer"));
                Assert.AreEqual("12.346 km neg", (-b).ToString("#,##0.000 UL pos;#,##0.000 UL neg|kilometer"));
                Assert.AreEqual("25.68 m*m", d.ToString("NL"));
                Assert.AreEqual("25.68 m²", d.ToString("NL|?"));
            }
            finally 
            {
                Thread.CurrentThread.CurrentCulture = defaultCultureInfo;
            }
        }
开发者ID:codetuner,项目名称:Arebis.Common,代码行数:39,代码来源:UnitAmountTests.cs

示例5: Percentage01Test

        public void Percentage01Test()
        {
            Unit percent = new Unit("percent", "%", 0.01m, Unit.None);

            Amount a = new Amount(15m, percent);
            Amount b = new Amount(300m, TimeUnits.Minute);
            
            Assert.AreEqual("15 %", a.ToString("0 UL"));
            Assert.AreEqual(0.15m, (decimal)a);
            Console.WriteLine(a * b);
            Assert.AreEqual(45m, (a * b).ConvertedTo(TimeUnits.Minute).Value);
        }
开发者ID:codetuner,项目名称:Arebis.Common,代码行数:12,代码来源:UnitAmountTests.cs


注:本文中的Amount.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。