當前位置: 首頁>>代碼示例>>C#>>正文


C# Currency.Equals方法代碼示例

本文整理匯總了C#中System.Currency.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# Currency.Equals方法的具體用法?C# Currency.Equals怎麽用?C# Currency.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Currency的用法示例。


在下文中一共展示了Currency.Equals方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CurrencyHasValueEquality

        public void CurrencyHasValueEquality()
        {
            var currency1 = new Currency("USD");
            var currency2 = new Currency("USD");
            object boxedCurrency2 = currency2;

            currency1.Equals(currency2).ShouldBe(true);
            currency1.Equals(boxedCurrency2).ShouldBe(true);
        }
開發者ID:madhon,項目名稱:money-type-for-the-clr,代碼行數:9,代碼來源:CurrencyTests.cs

示例2: PrintCurrency

 /// <summary>
 /// this can be reused for whatever currency type you would like to add if you need more in the future
 /// </summary>
 /// <param name="currency"></param>
 /// <param name="userBalance"></param>
 /// <returns></returns>
 public static String PrintCurrency(Currency currency, decimal dollarAmmount)
 {
     if (currency.Equals(Currency.USD))
     {
         return String.Format("{0:C}", dollarAmmount);
     }
     else
     {
         decimal exchangeRate = GetTransferRate(Enum.GetName(typeof(Currency), currency));
         return String.Format("{0:f2} {1}", (dollarAmmount * exchangeRate), Enum.GetName(typeof(Currency), currency));
     }
 }
開發者ID:alexcompton,項目名稱:BankConsole,代碼行數:18,代碼來源:Money.cs

示例3: EqualsTest

        public void EqualsTest()
        {
            string currencyName = "US";
            string symbol = "USD";
            Currency target = new Currency(currencyName, symbol);

            bool actual;
            actual = target.Equals(null);
            Assert.AreEqual(false, actual);

            // currencies are equal if the symbols match
            currencyName = "United states dollar";
            symbol = "USD";
            Currency target2 = new Currency(currencyName, symbol);

            actual = target.Equals(target2);
            Assert.AreEqual(true, actual);
        }
開發者ID:robukoo,項目名稱:SimpleBankingSystem,代碼行數:18,代碼來源:CurrencyTest.cs


注:本文中的System.Currency.Equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。