PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

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.

One Comment on “Which code segment should you use?


Leave a Reply