本文整理汇总了C#中System.Currency.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Currency.ToString方法的具体用法?C# Currency.ToString怎么用?C# Currency.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Currency
的用法示例。
在下文中一共展示了Currency.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
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 " +
"-$50.50 to a Currency:");
checked
{
balance = (Currency)(-50.50);
Console.WriteLine("Result is " + balance.ToString());
}
}
catch (Exception e)
{
Console.WriteLine("Exception occurred: " + e.Message);
}
Console.ReadLine();
}
示例2: GetTransactionsList
private static List<Transaction> GetTransactionsList(string fileName, Currency currency, string price, string quantity, string fileId, string userId)
{
var transactionList = new List<Transaction>();
transactionList.Add(new Transaction()
{
invoice_number = fileId + "_" + userId,
amount = new Amount()
{
currency = currency.ToString().ToUpper(),
total = price, // Total must be equal to sum of shipping, tax and subtotal.
},
item_list = new ItemList()
{
items = new List<Item>()
{
new Item()
{
name = fileName,
currency = currency.ToString().ToUpper(),
price = price,
quantity = quantity,
sku = fileId
}
}
}
});
return transactionList;
}
示例3: GetCurrencyInfo
public CurrencyInfo GetCurrencyInfo(Currency currency)
{
CurrencyInfoResponse currencyInfoResponse = restClient.GetResponse<CurrencyInfoResponse>(String.Format("BTC{0}/money/currency", currency.ToString()), Method.POST, null, AccessType.Public);
if(currencyInfoResponse.CurrencyInfo == null)
throw new Exception("Failed to deserialize JSON object of type " + typeof(CurrencyInfo) + ". " + MtGoxRestClient.lastResponse);
return currencyInfoResponse.CurrencyInfo;
}
示例4: GetDepth
public Depth GetDepth(Currency currency)
{
DepthResponse depthResponse = restClient.GetResponse<DepthResponse>(String.Format("BTC{0}/money/depth/fetch", currency.ToString()), Method.GET, null, AccessType.Public);
if (depthResponse.Depth == null)
throw new Exception("Failed to deserialize JSON object of type " + typeof(Depth) + ". " + MtGoxRestClient.lastResponse);
return depthResponse.Depth;
}
示例5: buyBTC
/// <summary>
/// 0/buyBTC.php
/// </summary>
public List<Order> buyBTC(double amount, Currency currency, double price = 0.0)
{
try
{
string url = (this.baseURL) + "0/buyBTC.php";
string postData;
if (price == 0.0)
postData = "amount=" + amount + "¤cy=" + currency.ToString();
else
postData = "amount=" + amount + "&price=" + price + "¤cy=" + currency.ToString();
string responseStr = DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData);
var resp = JSON.Instance.ToObject<OrderResponse>(responseStr);
return resp.orders;
}
catch (Exception ex)
{
return null;
}
}
示例6: CreateOrder
public OrderCreateResponse CreateOrder(Currency currency, OrderType type, double amount, double? price)
{
NameValueCollection nvc = new NameValueCollection
{
{"type", type.ToString().ToLower()},
{"amount_int", (Math.Round(amount, 8)*100000000).ToString()}
};
if(price != null)
nvc.Add("price_int", (Math.Round((double)price,5)*100000).ToString());
return restClient.GetResponse<OrderCreateResponse>(String.Format("BTC{0}/money/order/add", currency.ToString()), Method.POST, nvc, AccessType.Private);
}
示例7: LicenseBound
protected void LicenseBound(Object sender, RepeaterItemEventArgs e)
{
var cartProvider = (ICartProvider)MarketplaceProviderManager.Providers["CartProvider"];
ICart _cart = cartProvider.GetCurrentCart();
_currency = _cart.Currency;
Literal _name = (Literal)e.Item.FindControl("LicenseType");
Literal _price = (Literal)e.Item.FindControl("LicensePrice");
ImageButton _addToCart = (ImageButton)e.Item.FindControl("LicenseAddToCart");
var License = (ILicense)e.Item.DataItem;
switch (License.LicenseType)
{
case LicenseType.Domain:
_name.Text = "Domain";
break;
case LicenseType.IP:
_name.Text = "IP";
break;
case LicenseType.Unlimited:
_name.Text = "Unlimited";
break;
case LicenseType.SourceCode:
_name.Text = "Source Code";
break;
default:
break;
}
_price.Text = DeliCurrency.FriendlyConvertFromEuro((decimal)License.Price, DeliCurrency.FromSymbol(_currency.ToString()));
_addToCart.CommandArgument = License.Id.ToString();
if (!String.IsNullOrEmpty(Project.GACode))
{
var eventCategory = "_" + Project.Name.ToLower().Replace(" ", "");
_addToCart.OnClientClick = "vendorTracker._trackEvent('" + eventCategory + "', 'Add To Cart - " + _name.Text + "', '" + Project.Name + " " + _name.Text + "'," + License.Price + ");";
}
}
示例8: ToAUD
public static decimal ToAUD(decimal price, Currency sourceCurrency, Currency destinationCurrency)
{
try
{
var client = new WebClient();
var response = client.DownloadString(string.Format("http://www.google.com/ig/calculator?hl=en&q={0}{1}=?{2}", price, sourceCurrency.ToString(), destinationCurrency.ToString()));
string value = response.Substring(response.IndexOf("rhs"));
value = value.Substring(0, value.IndexOf(","));
string decimalValue = "";
foreach (char c in value)
{
if (char.IsDigit(c) || c == '.')
decimalValue += c;
}
return Math.Round(Convert.ToDecimal(decimalValue), 2);
}
catch
{
return 0;
}
}
示例9: InsertBondLimit
public static int InsertBondLimit(int? counterpartyID, int? counterpartyGroupID, double limitValue, Currency cur,
bool considerRevRepo, DateTime startDate)
{
if (counterpartyID == null && counterpartyGroupID == null)
throw new ArgumentException("counterpartyID == null && counterpartyGroupID == null");
if (counterpartyID != null && counterpartyGroupID != null)
throw new ArgumentException("counterpartyID != null && counterpartyGroupID != null");
if (limitValue <= 0)
throw new ArgumentException("limitValue <= 0");
string script = @"
declare @limitID int;
set @limitID = (select max(ID)+1 from t_Cpty_Limit);
declare @fullName nvarchar(300);
declare @shortName nvarchar(300);
if (@cptyID is not null)
select @fullName = Client_Name, @shortName = Client_ShortName from t_Client where ID = @cptyID;
else
select @fullName = NameCptyGroup, @shortName = SNameCptyGroup from t_CptyGroup where ID = @cptyGroupID;
insert into t_Cpty_Limit(ID, MasterLimitType, Limit_Type, Limit_Value, Limit_Currency, Limit_Unit, Limit_Date_Start, InstrumentType_ID,
Cpty_ID, CtptyGroup_ID, Cpty_ShortName, Cpty_Name, PortfolioGroup_ID)
values(@limitID, 'counterparty', 'credit', @limitValue, @limitCurrency, 'currency', @startDate, @instrumentType_ID,
@cptyID, @cptyGroupID, @shortName, @fullName, null)";
SqlCommand cmd = DBHelper.CreateCommand(RiskSettings.ConnStr, script,
DBHelper.CreateParameter("@limitValue", limitValue),
DBHelper.CreateParameter("@limitCurrency", cur.ToString().ToUpper()),
DBHelper.CreateParameter("@startDate", startDate),
DBHelper.CreateParameter("@instrumentType_ID", considerRevRepo ? -1 : (int?)null),
DBHelper.CreateParameter("@cptyID", counterpartyID), DBHelper.CreateParameter("@cptyGroupID", counterpartyGroupID));
DBHelper.ExecuteNonQuery(cmd);
return 0;
}
示例10: getDepth
/// <summary>
/// 0/data/getDepth.php
/// </summary>
public Depth getDepth(Currency currency)
{
try
{
string url = (this.baseURL) + "0/data/getDepth.php?currency=" + currency.ToString();
string postData = "";
string responseStr = DoAuthenticatedAPIPost(url, apiKey, apiSecret, postData);
Depth returnValue = new Depth();//Depth.getObjects(responseStr);
return returnValue;
}
catch (Exception ex)
{
return null;
}
}
示例11: GetFutureSearchCriteria
public static string GetFutureSearchCriteria(string description = "", string root = "", FutureType futureType = FutureType.Electronic,
Currency currency = Currency.USD, bool includeExpired = false, CountryCode country = CountryCode.ALL)
{
StringBuilder criteria = new StringBuilder(255);
Append(criteria, "c=" + SearchCategory.Future.ToString());
if (description != string.Empty) Append(criteria, "desc=" + description);
if (root != string.Empty) Append(criteria, "r=" + root);
if (futureType != FutureType.Electronic) Append(criteria, "FT=" + futureType.ToString());
if (currency != Currency.USD) Append(criteria, "Cur=" + currency.ToString());
if (includeExpired) Append(criteria, "Exp=true");
if (country != CountryCode.ALL) Append(criteria, "Cnt=" + country.ToString());
return criteria.ToString();
}
示例12: AddCell
public void AddCell(Currency text)
{
AddCell(text.ToString());
}
示例13: GetTrades
public TradeResponse GetTrades(Currency currency, DateTime? fromDateTime)
{
TradeResponse tradeResponse;
if (fromDateTime.HasValue)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
TimeSpan span = ((DateTime)fromDateTime - epoch);
Int64 since = (Int64)Decimal.Round(Decimal.Divide(span.Ticks, 10), 0);
tradeResponse = restClient.GetResponse<TradeResponse>(String.Format("BTC{0}/money/trades/fetch?since={1}", currency.ToString(), since), Method.GET, null, AccessType.Public);
}
else
{
tradeResponse = restClient.GetResponse<TradeResponse>(String.Format("BTC{0}/money/trades/fetch", currency.ToString()), Method.GET, null, AccessType.Public);
}
if (tradeResponse.Trades == null)
throw new Exception("Failed to deserialize JSON object of type " + typeof(List<Trade>) + ". " + MtGoxRestClient.lastResponse);
return tradeResponse;
}
示例14: GetTicker
public Ticker GetTicker(Currency currency)
{
MtGoxTickerResponse tickerResponse = restClient.GetResponse<MtGoxTickerResponse>(String.Format("BTC{0}/money/ticker", currency.ToString()), Method.GET, null, AccessType.Public);
if (tickerResponse.Ticker == null)
throw new Exception("Failed to deserialize JSON object of type " + typeof(MtGoxTicker) + ". " + MtGoxRestClient.lastResponse);
return new Ticker(tickerResponse.Ticker);
}
示例15: ToStringTest
public void ToStringTest()
{
Symbols sym = Symbols.USD;
Decimal amount = 2.2M;
Currency target = new Currency(sym, amount);
string expected = "USD 2.20";
string actual;
actual = target.ToString();
Assert.AreEqual(expected, actual);
}