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


C# Currency.ToString方法代码示例

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


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

示例1: Main

        static void Main()
        {
            try
             {
            Currency balance = new Currency(50,35);
            Console.WriteLine(balance);
            Console.WriteLine("balance is " + balance);
            Console.WriteLine("balance is (using ToString()) " + balance.ToString());

            float balance2= balance;
            Console.WriteLine("After converting to float, = " + balance2);
            balance = (Currency) balance2;
            Console.WriteLine("After converting back to Currency, = " + balance);

            Console.WriteLine(
               "Now attempt to convert out of range value of -$100.00 to a Currency:");
            checked
            {
               balance = (Currency) (-50.5);
               Console.WriteLine("Result is " + balance.ToString());
            }
             }
             catch(Exception e)
             {
            Console.WriteLine("Exception occurred: " + e.Message);
             }
        }
开发者ID:alannet,项目名称:example,代码行数:27,代码来源:SimpleCurrency.cs

示例2: FromCurrency

 public static CurrencyDto FromCurrency(Currency currency)
 {
     return new CurrencyDto
     {
         Id = (int)currency,
         Code = currency.ToString()
     };
 }
开发者ID:andrewtsw,项目名称:Interesnee.BadBroker,代码行数:8,代码来源:CurrencyDto.cs

示例3: ExchangeRate

 //Возвращает exchangeRate
 private double ExchangeRate(Currency cur1, Currency cur2)
 {
     if (cur1 == cur2)
         return 1.000;
     else
     {
         string index = string.Format(cur2.ToString() + "-" + cur1.ToString());
         return _exchangeRates[index];
     }
 }
开发者ID:iemee,项目名称:AlphaBank,代码行数:11,代码来源:ExchangeService.cs

示例4: CurrencyTypes

            public void CurrencyTypes(Currency currency)
            {
                var request = new SagePay.Request.Refund.WebSageRefund(SageConfiguration.CONFIG_TYPE, TEST_URL);
                request.Transaction = RefundRequest.SampleRequest();
                request.Transaction.Currency = currency;
                var encode = request.Encode();

                Assert.Equal(encode["Currency"], currency.ToString().ToUpper());
            }
开发者ID:OrangeT,项目名称:SagePay,代码行数:9,代码来源:WebSageRefund.cs

示例5: Main

        static void Main(string[] args)
        {
            Currency currency = new Currency(50, 35);
            Console.WriteLine(currency); // 这里默认隐式转换为float
            Console.WriteLine("currency is " + currency);
            Console.WriteLine("tostring is " + currency.ToString());

            float f = currency; // 需要类型强制转换
            Console.WriteLine("converting to float " + f);

            currency = (Currency)f; // 需要显示转换
            Console.WriteLine("convert back " + currency);

            currency = (Currency)(-50.50); //
            Console.WriteLine("out of range " + currency);
        }
开发者ID:devwh,项目名称:CSharp,代码行数:16,代码来源:Program.cs


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