Get Two letter name for all Countries - CSharp System.Globalization

CSharp examples for System.Globalization:Country

Description

Get Two letter name for all Countries

Demo Code

// Copyright (c) Clickberry, Inc. All rights reserved.
using System.Linq;
using System.Globalization;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using System;/*from  w ww  . j  a  va2s.  c  o  m*/

public class Main{
        private static IEnumerable<string> GetCountries()
        {
            return from ri in
                from ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures)
                select new RegionInfo(ci.LCID)
                group ri by ri.TwoLetterISORegionName
                into g
                select g.Key;
        }
}

Related Tutorials