當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。