本文整理匯總了C#中System.Currency.Parse方法的典型用法代碼示例。如果您正苦於以下問題:C# Currency.Parse方法的具體用法?C# Currency.Parse怎麽用?C# Currency.Parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Currency
的用法示例。
在下文中一共展示了Currency.Parse方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: op_Parse_CultureInfoSpanish_stringEuro
public void op_Parse_CultureInfoSpanish_stringEuro()
{
var obj = new Currency("£", 2);
var expected = new Money
{
Amount = -123456.78m,
Currency = obj
};
var actual = obj.Parse(new CultureInfo("en-GB"), "-£123,456.78");
Assert.Equal(expected, actual);
}
示例2: op_Parse_CultureInfoBritish_stringSterling
public void op_Parse_CultureInfoBritish_stringSterling()
{
var obj = new Currency("€", 2);
var expected = new Money
{
Amount = -123456.78m,
Currency = obj
};
var actual = obj.Parse(new CultureInfo("es-ES"), "-123.456,78 €");
Assert.Equal(expected, actual);
}
示例3: op_Parse_CultureInfo_stringNull
public void op_Parse_CultureInfo_stringNull()
{
var obj = new Currency("€", 2);
Assert.Throws<ArgumentNullException>(() => obj.Parse(new CultureInfo("en-GB"), null));
}
示例4: op_Parse_CultureInfo_stringEmpty
public void op_Parse_CultureInfo_stringEmpty()
{
var obj = new Currency("€", 2);
Assert.Throws<ArgumentOutOfRangeException>(() => obj.Parse(new CultureInfo("en-GB"), string.Empty));
}
示例5: op_Parse_CultureInfoNull_string
public void op_Parse_CultureInfoNull_string()
{
var obj = new Currency("€", 2);
Assert.Throws<ArgumentNullException>(() => obj.Parse(null, "-123.456,78 €"));
}