Quick access to country and region information on Windows systems

Source: Internet
Author: User

The Windows system contains data from more than 200 countries and regions, and sometimes programming requires this information. The following code can help you get this information quickly.
The console statement is commented out and the analysis can be done faster.

1 Static voidMain (string[] args) {2Console.WriteLine ("start!");3     //Here you can modify the file path and file name. 4     varSW =NewStreamWriter (NewFileStream ("RegionInfo.txt", FileMode.OpenOrCreate)); 5     6     //get the properties of the RegionInfo class by reflection, write to the file stream as a caption7Sw. WriteLine ("Culture,"+string. Join (",",typeof(RegionInfo). GetProperties (). Select (p =p.name). ToArray ()));8     9     //defining country and region information in Windows systems use the Culture parameter, which contains 2-bit country codes and 2-bit area codesTen      for(vari =0x00; I <0xFF; i++) { One          for(varj =0x00; J <0xFF; J + +) { A             varCulture = (I <<8) + J;//build the Culture parameter, I is the country code, J is the region code -RegionInfo ri =NULL; -             //not all of the Culture parameters are valid parameters, so you need to handle instantiating exceptions the             Try { -RI =NewRegionInfo (culture); -                 //gets the property value of the instantiated object by reflection and writes to the file stream -Sw. WriteLine (Culture +","+string. Join (",", RI. GetType (). GetProperties (). Select (p = P.getvalue (ri,NULL). ToString ()). ToArray ())); +Console.WriteLine ("0x{0:x}\tdone!", culture); -}Catch { +                 Continue; A             } at         } -     } - SW. Flush (); - SW. Close (); -Console.WriteLine ("All done!"); - Console.readkey (); in}

In addition to the RegionInfo class contains country and region information in C #, the CultureInfo class also contains other information related to language, text, etc., and can be substituted for analysis by itself.

This article from the Flying Dust Blog, reproduced please indicate the source.

Quick access to country and region information on Windows systems

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.