PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

You are developing a fiscal report for a customer.
Your customer has a main office in the United States and a satellite office in Mexico.
You need to ensure that when users in the satellite office generate the report, the current date is displayed in Mexican Spanish format.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
DateTimeFormatInfo dtfi = new CultureInfo(“es-MX”,false).DateTimeFormat;
DateTime dt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);
string dateString = dt.ToString(dtfi.LongDatePattern);

B.
Calender cal = new CultureInfo(“es-MX”,false).Calender;
DateTime dt = new DateTime(DateTime.Today.Year,DateTime.Today.Month,DateTime.Today.Day);
string dateString = dt.ToString();

C.
string dateString = DateTimeFormatInfo.CurrentInfo.GetMonthName(DateTime.Today.Month);

D.
string dateString = DateTime.Today.Month.ToString(“es-MX”)

Explanation:
Create a Mexican Spanish CultureInfo object. Convert the date to a string using the DateTimeFormatInfo returned by the CultureInfo object.
B does not use the CultureInfo object to convert the date to a string.
C does not use the Mexican Spanish culture.
D the DateTime.ToString() method cannot take a string code representation of the culture.

One Comment on “Which code segment should you use?


Leave a Reply