Which code segment should you use?

You create an application that stores information about your customers who reside in various regions.
You are developing internal utilities for this application. You need to gather regional information about your customers in Canada. Which code segment should you use?

You create an application that stores information about your customers who reside in various regions.
You are developing internal utilities for this application. You need to gather regional information about your customers in Canada. Which code segment should you use?

A.
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) {
// Output the region information…}

B.
CultureInfo cultureInfo = new CultureInfo(“CA”);
// Output the region information…

C.
RegionInfo regionInfo = new RegionInfo(“CA”);
// Output the region information…

D.
RegionInfo regionInfo = new RegionInfo(“”);
if (regionInfo.Name == “CA”) {
// Output the region information…}

Explanation:
The RegionInfo class can be used to get information about a region.
A & B CultureInfo is used to control formatting, sorting & comparing of culture sensitive data. E.g currencies, calendar dates etc.
D Does not initialise the RegionInfo object correctly i.e to Canada.



Leave a Reply 1

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


networkmanagers

networkmanagers

I choose C