Which code segment should you use?

You are developing an application for a client residing in Hong Kong. You need to display negative currency values by using a minus sign. Which code segment should you use?

You are developing an application for a client residing in Hong Kong. You need to display negative currency values by using a minus sign. Which code segment should you use?

A.
NumberFormatInfo culture = new CultureInfo(“zh-HK”).NumberFormat; culture.NumberNegativePattern = 1;
return numberToPrint.ToString(“C”, culture);

B.
NumberFormatInfo culture = new CultureInfo(“zh-HK”).NumberFormat; culture.CurrencyNegativePattern = 1;
return numberToPrint.ToString(“C”, culture);

C.
CultureInfo culture = new CultureInfo(“zh-HK”);
return numberToPrint.ToString(“()”, culture);

D.
CultureInfo culture = new CultureInfo(“zh-HK”);
return numberToPrint.ToString(“()”, culture);

Explanation:
Use CurrencyNegativePattern property set to 1 to display negative currency values with a minus sign.
A will give a minus sign for negative numbers but not for negative currencies.
C & D The culture has not been to display a minus sign for currency.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


networkmanagers

networkmanagers

I have the same idea. B