本文整理汇总了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);
}
}
示例2: FromCurrency
public static CurrencyDto FromCurrency(Currency currency)
{
return new CurrencyDto
{
Id = (int)currency,
Code = currency.ToString()
};
}
示例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];
}
}
示例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());
}
示例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);
}